-
Notifications
You must be signed in to change notification settings - Fork 1
/
wsgi.py
40 lines (29 loc) · 1.08 KB
/
wsgi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# -*- coding: utf-8 -*-
from gevent import monkey
monkey.patch_all()
import os
import leancloud
from app import app
from cloud import engine
APP_ID = os.environ['LEANCLOUD_APP_ID']
APP_KEY = os.environ['LEANCLOUD_APP_KEY']
MASTER_KEY = os.environ['LEANCLOUD_APP_MASTER_KEY']
PORT = int(os.environ['LEANCLOUD_APP_PORT'])
leancloud.init(APP_ID, app_key=APP_KEY, master_key=MASTER_KEY)
# 如果需要使用 master key 权限访问 LeanCLoud 服务,请将这里设置为 True
leancloud.use_master_key(False)
application = engine
if __name__ == '__main__':
# 只在本地开发环境执行的代码
from gevent.pywsgi import WSGIServer
from geventwebsocket.handler import WebSocketHandler
from werkzeug.serving import run_with_reloader
from werkzeug.debug import DebuggedApplication
@run_with_reloader
def run():
global application
app.debug = True
application = DebuggedApplication(application, evalex=True)
server = WSGIServer(('0.0.0.0', PORT), application, handler_class=WebSocketHandler)
server.serve_forever()
run()