Skip to content
Myr

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 file

Take it

The walk stopped after 200 commits: lines older than b57a076 point at it.

Merge pull request #1380 from KWinston/masterMarkus Unterwaditzerbefore adoptionb57a076

lines 1–7why, one step back
1.. _server:
23Development Server4==================56.. currentmodule:: flask7

resolve merge conflictsKenneth Reitzbefore adoption31174fe

line 8why, one step back
8Starting with Flask 0.11 there are multiple built-in ways to run a

Merge pull request #1380 from KWinston/masterMarkus Unterwaditzerbefore adoptionb57a076

lines 9–14why, one step back
9development server. The best one is the :command:`flask` command line utility
10but you can also continue using the :meth:`Flask.run` method.1112Command Line13------------14

Add Support for FLASK_ENV (#2570)Armin Ronacherbefore adoption2433522

lines 15–18why, one step back
15The :command:`flask` command line script (:ref:`cli`) is strongly
16recommended for development because it provides a superior reload17experience due to how it loads the application. The basic usage is like18this::

Merge pull request #1380 from KWinston/masterMarkus Unterwaditzerbefore adoptionb57a076

line 19why, one step back
19

resolve merge conflictsKenneth Reitzbefore adoption31174fe

line 20why, one step back
20 $ export FLASK_APP=my_application

Add Support for FLASK_ENV (#2570)Armin Ronacherbefore adoption2433522

line 21why, one step back
21 $ export FLASK_ENV=development

resolve merge conflictsKenneth Reitzbefore adoption31174fe

line 22why, one step back
22 $ flask run

Merge pull request #1380 from KWinston/masterMarkus Unterwaditzerbefore adoptionb57a076

line 23why, one step back
23

Merge pull request #2593 from pallets/env-docsDavid Lordbefore adoptionc3a9978

lines 24–25why, one step back
24This enables the development environment, including the interactive
25debugger and reloader, and then starts the server on

Merge pull request #1380 from KWinston/masterMarkus Unterwaditzerbefore adoptionb57a076

lines 26–28why, one step back
26*http://localhost:5000/*.
2728The individual features of the server can be controlled by passing more

Merge pull request #2593 from pallets/env-docsDavid Lordbefore adoptionc3a9978

line 29why, one step back
29arguments to the ``run`` option. For instance the reloader can be

Merge pull request #1380 from KWinston/masterMarkus Unterwaditzerbefore adoptionb57a076

lines 30–31why, one step back
30disabled::
31

resolve merge conflictsKenneth Reitzbefore adoption31174fe

line 32why, one step back
32 $ flask run --no-reload

Add Support for FLASK_ENV (#2570)Armin Ronacherbefore adoption2433522

lines 33–35why, one step back
33
34.. note::35

Merge pull request #2593 from pallets/env-docsDavid Lordbefore adoptionc3a9978

lines 36–40why, one step back
36 Prior to Flask 1.0 the :envvar:`FLASK_ENV` environment variable was
37 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.

Merge pull request #1380 from KWinston/masterMarkus Unterwaditzerbefore adoptionb57a076

lines 41–54why, one step back
41
42In 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 for

resolve merge conflictsKenneth Reitzbefore adoption31174fe

lines 55–59why, one step back
55development 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).

Merge pull request #1380 from KWinston/masterMarkus Unterwaditzerbefore adoptionb57a076

lines 60–62why, one step back
60
61It is however still a perfectly valid method for invoking a non automatic62reloading application.