New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add auto reloader in development #12

Merged
merged 1 commit into from Nov 1, 2016
Jump to file or symbol
Failed to load files and symbols.
+16 −6
Diff settings

Always

Just for now

View
@@ -1,5 +1,6 @@
gevent>=1.0.2,<2.0.0
gevent-websocket>=0.9.5,<1.0.0
leancloud-sdk>=1.0.9,<=2.0.0
Werkzeug>=0.11.11,<1.0.0
Flask>=0.10.1,<1.0.0
Flask-Sockets>=0.1,<1.0
View
@@ -20,7 +20,7 @@ class Todo(Object):
def show():
try:
todos = Query(Todo).descending('createdAt').find()
except LeanCloudError, e:
except LeanCloudError as e:
if e.code == 101: # 服务端对应的 Class 还没创建
todos = []
else:
View
19 wsgi.py
@@ -6,8 +6,6 @@
import os
import leancloud
from gevent.pywsgi import WSGIServer
from geventwebsocket.handler import WebSocketHandler
from app import app
from cloud import engine
@@ -26,6 +24,17 @@
if __name__ == '__main__':
# 只在本地开发环境执行的代码
app.debug = True
server = WSGIServer(('localhost', PORT), application, handler_class=WebSocketHandler)
server.serve_forever()
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(('localhost', PORT), application, handler_class=WebSocketHandler)
server.serve_forever()
run()