The decision to make does not work for me.
Gunicorn is a preliminary infrastructure and, apparently, the Flask debugging program does not work in a forking environment .
Attention
Despite the fact that the interactive debugger does not work in (which makes it almost impossible to use production servers) [...]
Even if you set app.debug = True , you still get only a blank page with the message Internal Server Error if you use gunicorn testserver:app . The best you can do with a gun is to run it with gunicorn --debug testserver:app . This gives you a trace in addition to reporting an internal server error. However, these are only the same text traces that you see in the terminal, not the Flask debugger.
Adding an if __name__ ... section to testerver.py and running python testserver.py to start the server in development will give you a Flask debugger. In other words, do not use gunicorn in development if you want a Flask debugger.
app = Flask(__name__) app.config['DEBUG'] = True if __name__ == '__main__': app.run()
Tip for Heroku users:
Personally, I still like to use foreman start instead of python testserver.py , since it sets all env variables for me . To get this done:
Procfile Content
web: bin/web
The contents of bin/web , the file refers to the root of the project
#!/bin/sh if [ "$FLASK_ENV" == "development" ]; then python app.py else gunicorn app:app -w 3 fi
In development, create an .env file relative to the project root with the following contents (docs here )
FLASK_ENV=development DEBUG=True
Also, be sure to change the line app.config['DEBUG']... in testserver.py so that it will not run the flag in debug mode during production.
app.config['DEBUG'] = os.environ.get('DEBUG', False)
Nick Zalutskiy Dec 19 '12 at 6:26 2012-12-19 06:26
source share