server.rst
This file
Path
docs/server.rst
62 lines · 1.9 KiB
Last changed by
Merge pull request #2593 from pallets/env-docsDavid Lordbefore adoptionc3a9978
History of this fileTake it
The walk stopped after 200 commits: lines older than d2a46dc point at it.
fix doc build errorDavid Lordbefore adoptiond2a46dc
lines 1–14why, one step back1.. _server:23Development Server4==================56.. currentmodule:: flask78Starting with Flask 0.11 there are multiple built-in ways to run a9development server. The best one is the :command:`flask` command line utility10but you can also continue using the :meth:`Flask.run` method.1112Command Line13------------14Add Support for FLASK_ENV (#2570)Armin Ronacherbefore adoption2433522
lines 15–18why, one step back15The :command:`flask` command line script (:ref:`cli`) is strongly16recommended for development because it provides a superior reload17experience due to how it loads the application. The basic usage is like18this::fix doc build errorDavid Lordbefore adoptiond2a46dc
lines 19–20why, one step back1920 $ export FLASK_APP=my_applicationAdd Support for FLASK_ENV (#2570)Armin Ronacherbefore adoption2433522
line 21why, one step back21 $ export FLASK_ENV=developmentfix doc build errorDavid Lordbefore adoptiond2a46dc
lines 22–23why, one step back22 $ flask run23Merge pull request #2593 from pallets/env-docsDavid Lordbefore adoptionc3a9978
lines 24–25why, one step back24This enables the development environment, including the interactive25debugger and reloader, and then starts the server onfix doc build errorDavid Lordbefore adoptiond2a46dc
lines 26–28why, one step back26*http://localhost:5000/*.2728The individual features of the server can be controlled by passing moreMerge pull request #2593 from pallets/env-docsDavid Lordbefore adoptionc3a9978
line 29why, one step back29arguments to the ``run`` option. For instance the reloader can befix doc build errorDavid Lordbefore adoptiond2a46dc
lines 30–32why, one step back30disabled::3132 $ flask run --no-reloadAdd Support for FLASK_ENV (#2570)Armin Ronacherbefore adoption2433522
lines 33–35why, one step back3334.. note::35Merge pull request #2593 from pallets/env-docsDavid Lordbefore adoptionc3a9978
lines 36–40why, one step back36 Prior to Flask 1.0 the :envvar:`FLASK_ENV` environment variable was37 not supported and you needed to enable debug mode by exporting38 ``FLASK_DEBUG=1``. This can still be used to control debug mode, but39 you should prefer setting the development environment as shown40 above.fix doc build errorDavid Lordbefore adoptiond2a46dc
lines 41–62why, one step back4142In Code43-------4445The alternative way to start the application is through the46:meth:`Flask.run` method. This will immediately launch a local server47exactly the same way the :command:`flask` script does.4849Example::5051 if __name__ == '__main__':52 app.run()5354This works well for the common case but it does not work well for55development which is why from Flask 0.11 onwards the :command:`flask`56method is recommended. The reason for this is that due to how the reload57mechanism works there are some bizarre side-effects (like executing58certain code twice, sometimes crashing without message or dying when a59syntax or import error happens).6061It is however still a perfectly valid method for invoking a non automatic62reloading application.