I\'m working on on a Flask app using Flask\'s built in dev server. I start it using Flask-Script. I want to switch to using Gunicorn as the web server. To do so, do I nee
Based the answer of the Sean, I also wrote a version more preferred to me.
@manager.option('-h', '--host', dest='host', default='127.0.0.1')
@manager.option('-p', '--port', dest='port', type=int, default=6969)
@manager.option('-w', '--workers', dest='workers', type=int, default=3)
def gunicorn(host, port, workers):
"""Start the Server with Gunicorn"""
from gunicorn.app.base import Application
class FlaskApplication(Application):
def init(self, parser, opts, args):
return {
'bind': '{0}:{1}'.format(host, port),
'workers': workers
}
def load(self):
return app
application = FlaskApplication()
return application.run()
you can run the gunicorn using command like thispython manager.py gunicorn