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.
cross-platform gevent-based WSGI server command for Flask-Script
@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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment