In bottle all i have to do to enable debug mode is:
from bottle import debug
application = Bottle()
app = application
debug(True)
How can i do the same in Flask framework?
If you click on the “Run and Debug” icon on the left hand side of the IDE or alternatively type Ctrl+Shift+D you will see the “RUN AND DEBUG” window. Now click on the “create a launch. json file” link and when prompted to “Select a debug configuration” choose “Python File Debug the currently active Python file”.
Flask Debug mode allows developers to locate any possible error and as well the location of the error, by logging a traceback of the error. The Flask debug mode also enables developers to interactively run arbitrary python codes, so that one can resolve and get to the root cause on why an error happened.
Command Line The flask run CLI command is the recommended way to run the development server. Use the --app option to point to your application, and the --debug option to enable debug mode.
Although Flask has a built-in web server, as we all know, it's not suitable for production and needs to be put behind a real web server able to communicate with Flask through a WSGI protocol.
To enable the debug mode I would add the following code to the flask app:
app.config['ENV'] = 'development'
app.config['DEBUG'] = True
app.config['TESTING'] = True
I would also sugest setting environment variables for the environment and debug.
$ export FLASK_ENV=development
$ export FLASK_DEBUG=1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With