Skip to content
Myr

server.rst

This file

Path

docs/server.rst

52 lines · 1.6 KiB

Last changed by

resolve merge conflictsKenneth Reitzbefore adoption31174fe

History of this file

Take it

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

Added a changelog entry for modules.Armin Ronacherbefore adoption5edc803

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 #1240 from defuz/docs-style-fix-2Markus Unterwaditzerbefore adoption6fcc2ae

line 9why, one step back
9development server. The best one is the :command:`flask` command line utility

Added a changelog entry for modules.Armin Ronacherbefore adoption5edc803

lines 10–14why, one step back
10but you can also continue using the :meth:`Flask.run` method.
1112Command Line13------------14

Merge pull request #1418 from alexwlchan/masterKeyan Pishdadianbefore adoptiondac45f6

line 15why, one step back
15The :command:`flask` command line script (:ref:`cli`) is strongly recommended for

Added a changelog entry for modules.Armin Ronacherbefore adoption5edc803

lines 16–18why, one step back
16development because it provides a superior reload experience due to how it
17loads the application. The basic usage is like this::18

resolve merge conflictsKenneth Reitzbefore adoption31174fe

lines 19–21why, one step back
19 $ export FLASK_APP=my_application
20 $ export FLASK_DEBUG=121 $ flask run

Added a changelog entry for modules.Armin Ronacherbefore adoption5edc803

line 22why, one step back
22

Merge pull request #1240 from defuz/docs-style-fix-2Markus Unterwaditzerbefore adoption6fcc2ae

line 23why, one step back
23This will enable the debugger, the reloader and then start the server on

Added a changelog entry for modules.Armin Ronacherbefore adoption5edc803

lines 24–29why, one step back
24*http://localhost:5000/*.
2526The individual features of the server can be controlled by passing more27arguments to the ``run`` option. For instance the reloader can be28disabled::29

resolve merge conflictsKenneth Reitzbefore adoption31174fe

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

Added a changelog entry for modules.Armin Ronacherbefore adoption5edc803

lines 31–36why, one step back
31
32In Code33-------3435The alternative way to start the application is through the36:meth:`Flask.run` method. This will immediately launch a local server

Merge pull request #1240 from defuz/docs-style-fix-2Markus Unterwaditzerbefore adoption6fcc2ae

line 37why, one step back
37exactly the same way the :command:`flask` script does.

Added a changelog entry for modules.Armin Ronacherbefore adoption5edc803

lines 38–44why, one step back
38
39Example::4041 if __name__ == '__main__':42 app.run()4344This works well for the common case but it does not work well for

resolve merge conflictsKenneth Reitzbefore adoption31174fe

lines 45–49why, one step back
45development which is why from Flask 0.11 onwards the :command:`flask`
46method is recommended. The reason for this is that due to how the reload47mechanism works there are some bizarre side-effects (like executing48certain code twice, sometimes crashing without message or dying when a49syntax or import error happens).

Added a changelog entry for modules.Armin Ronacherbefore adoption5edc803

lines 50–52why, one step back
50
51It is however still a perfectly valid method for invoking a non automatic52reloading application.