-
-
Save robbles/6313290 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def runserver(app, port=5000, profile_log=None): | |
"""Runs a development server.""" | |
from werkzeug.serving import run_with_reloader | |
from werkzeug.debug import DebuggedApplication | |
from werkzeug.contrib.profiler import ProfilerMiddleware | |
app.debug = True | |
port = int(port) | |
if profile_log: | |
f = open(profile_log, 'w') | |
wsgi = ProfilerMiddleware(app, f) | |
else: | |
wsgi = DebuggedApplication(app) | |
@run_with_reloader | |
def run_server(): | |
print('start server at: 127.0.0.1:%s' % port) | |
# import gevent in child process to avoid "gevent is only usable from a single thread" error | |
from gevent.wsgi import WSGIServer | |
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