flask.Flask.run¶
-
Flask.run(host=None, port=None, debug=None, **options)[source]¶ Runs the application on a local development server.
Do not use
run()in a production setting. It is not intended to meet security and performance requirements for a production server. Instead, see Application Deployment for WSGI server recommendations.If the
debugflag is set the server will automatically reload for code changes and show a debugger in case an exception happened.If you want to run the application in debug mode, but disable the code execution on the interactive debugger, you can pass
use_evalex=Falseas parameter. This will keep the debugger’s traceback screen active, but disable code execution.It is not recommended to use this function for development with automatic reloading as this is badly supported. Instead you should be using the flask command line script’s
runsupport.Keep in Mind
Flask will suppress any server error with a generic error page unless it is in debug mode. As such to enable just the interactive debugger without the code reloading, you have to invoke
run()withdebug=Trueanduse_reloader=False. Settinguse_debuggertoTruewithout being in debug mode won’t catch any exceptions because there won’t be any to catch.Changed in version 0.10: The default port is now picked from the
SERVER_NAMEvariable.Parameters: - host – the hostname to listen on. Set this to
'0.0.0.0'to have the server available externally as well. Defaults to'127.0.0.1'. - port – the port of the webserver. Defaults to
5000or the port defined in theSERVER_NAMEconfig variable if present. - debug – if given, enable or disable debug mode.
See
debug. - options – the options to be forwarded to the underlying
Werkzeug server. See
werkzeug.serving.run_simple()for more information.
- host – the hostname to listen on. Set this to