Skip to content

Instantly share code, notes, and snippets.

@lee-pai-long
Last active September 5, 2017 13:32
Show Gist options
  • Save lee-pai-long/4bfc10151249adb860e3e7704cf00f86 to your computer and use it in GitHub Desktop.
Save lee-pai-long/4bfc10151249adb860e3e7704cf00f86 to your computer and use it in GitHub Desktop.
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment