Skip to content

Instantly share code, notes, and snippets.

@wolf0403
Forked from lepture/gevent-flask.py
Last active August 29, 2015 14:02
Show Gist options
  • Save wolf0403/1635ecdf0b882d96cf22 to your computer and use it in GitHub Desktop.
Save wolf0403/1635ecdf0b882d96cf22 to your computer and use it in GitHub Desktop.
def runserver(port=5000, profile_log=None):
"""Runs a development server."""
from gevent.wsgi import WSGIServer
from werkzeug.serving import run_with_reloader
from werkzeug.debug import DebuggedApplication
from werkzeug.contrib.profiler import ProfilerMiddleware
port = int(port)
if profile_log:
f = open(profile_log, 'w')
wsgi = ProfilerMiddleware(app, f)
else:
wsgi = DebuggedApplication(app, True) # enable inline interpreter
@run_with_reloader
def run_server():
print('start server at: 127.0.0.1:%s' % port)
http_server = WSGIServer(('', port), wsgi)
http_server.serve_forever()
run_server()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment