Website.run#
- Website.run(host: Optional[str] = None, port: Optional[int] = None, debug: Optional[bool] = None, load_dotenv: bool = True, **options: Any) None#
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 /deploying/index 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.- 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'or the host in theSERVER_NAMEconfig variable if present.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.load_dotenv – Load the nearest
.envand.flaskenvfiles to set environment variables. Will also change the working directory to the directory containing the first file found.options – the options to be forwarded to the underlying Werkzeug server. See
werkzeug.serving.run_simple()for more information.
Changed in version 1.0: If installed, python-dotenv will be used to load environment variables from
.envand.flaskenvfiles.The
FLASK_DEBUGenvironment variable will overridedebug.Threaded mode is enabled by default.
Changed in version 0.10: The default port is now picked from the
SERVER_NAMEvariable.