lee-pai-long
3/15/2017 - 2:26 PM

WIP: Running werkzeug with gevent

WIP: Running werkzeug with gevent

[FLASK] Running werkzeug with gevent

WARNING: WIP since first test doesn't seems to work

With a create_app() function Factory, in run.py instead of something like this:


from project.app import create_app

app = create_app()

if __name__ == '__main__':
    app.run(host='127.0.0.1', port=5000)

We can have:


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

from project.app import create_app

@run_with_reloader
def run(app, host='127.0.0.1', port=5000):
    http_server = WSGIServer((localhost, port), DebuggedApplication(app))
    http_server.serve_forever()

app = create_app()

if __name__ == '__main__':
    run(app)