Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bmjjr/3f154e2ab881f60a08aea8574779e3c1 to your computer and use it in GitHub Desktop.
Save bmjjr/3f154e2ab881f60a08aea8574779e3c1 to your computer and use it in GitHub Desktop.

Revisions

  1. @darvid darvid created this gist May 31, 2015.
    23 changes: 23 additions & 0 deletions gistfile1.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    @manager.command
    def runserver(host="127.0.0.1", port=8000):
    """Run a gevent-based WSGI server."""
    port = int(port)

    wrapped_app = app
    if app.config.get("DEBUG", True):
    wrapped_app = werkzeug.debug.DebuggedApplication(app)

    server = WSGIServer(listener=(host, port), application=wrapped_app,
    handler_class=WebSocketHandler)

    def serve():
    print(" * Running on http://%s:%d/" % (host, port))
    server.serve_forever()

    if app.debug:
    # the watchdog reloader (with watchdog==0.8.3) appears to hang on
    # Windows 8.1, so we're using stat instead
    werkzeug.serving.run_with_reloader(
    serve, reloader_type="stat" if sys.platform == "win32" else "auto")
    else:
    serve()