q2mrbw
Last Updated: February 25, 2016
·
3.611K
· lepture

Gevent with debug support for Flask

Using gevent server instead of the default one by flask will loose the debug feature, and this snippet will enable debugger and reload support.

from gevent.wsgi import WSGIServer
from werkzeug.serving import run_with_reloader
from werkzeug.debug import DebuggedApplication

app = Flask(__name__)

@run_with_reloader
def run_server():
    http_server = WSGIServer(('', 5000), DebuggedApplication(app))
    http_server.serve_forever()

run_server()