Last active
January 30, 2020 15:29
-
-
Save lepture/4040127 to your computer and use it in GitHub Desktop.
gevent with werkzeug reload and debug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def runserver(port=5000, profile_log=None): | |
"""Runs a development server.""" | |
from gevent.wsgi import WSGIServer | |
from werkzeug.serving import run_with_reloader | |
from werkzeug.debug import DebuggedApplication | |
from werkzeug.contrib.profiler import ProfilerMiddleware | |
port = int(port) | |
if profile_log: | |
f = open(profile_log, 'w') | |
wsgi = ProfilerMiddleware(app, f) | |
else: | |
wsgi = DebuggedApplication(app) | |
@run_with_reloader | |
def run_server(): | |
print('start server at: 127.0.0.1:%s' % port) | |
http_server = WSGIServer(('', port), wsgi) | |
http_server.serve_forever() | |
run_server() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
run_with_reloader
不是一个 decorator 啊,这样得到的run_server
应该是个None
,不能调用的吧。而且 gevent 1.1 里面这个办法已经不管用了,需要重新写一个用 greenlet 运行 reloader 的
run_with_reloader
。