Last active
November 4, 2016 02:30
-
-
Save syfun/de17b0a50ba4625e277595f8a079ebf4 to your computer and use it in GitHub Desktop.
gevent-wsgi-reloader
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
# coding=utf-8 | |
from flask_script import Manager | |
from flask_seed.command import db | |
from gevent.wsgi import WSGIServer | |
from werkzeug.debug import DebuggedApplication | |
from werkzeug.serving import run_with_reloader | |
import config | |
from filemore import create_app | |
app = create_app() | |
manager = Manager(app) | |
manager.command(db) | |
@run_with_reloader | |
def run(): | |
http_server = WSGIServer( | |
(config.HOST, config.PORT), | |
DebuggedApplication(app, evalex=True) | |
) | |
http_server.serve_forever() | |
@manager.command | |
def runserver(): | |
app.logger.info('Start on {host}:{port}...'.format(host=config.HOST, port=config.PORT)) | |
run() | |
if __name__ == '__main__': | |
manager.run() |
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
#!/usr/bin/env python | |
# coding=utf-8 | |
from flask import Flask | |
from gevent.wsgi import WSGIServer | |
from werkzeug.serving import run_with_reloader | |
from werkzeug.debug import DebuggedApplication | |
app = Flask(__name__) | |
if __name__ == '__main__': | |
@run_with_reloader | |
def runserver(): | |
http_server = WSGIServer( | |
('0.0.0.0', 8080), | |
DebuggedApplication(app, evalex=True) | |
) | |
http_server.serve_forever() | |
runserver() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment