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

1.. _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------------1415The :command:`flask` command line script (:ref:`cli`) is strongly recommended for16development because it provides a superior reload experience due to how it17loads the application.  The basic usage is like this::1819    $ export FLASK_APP=my_application20    $ export FLASK_DEBUG=121    $ flask run2223This will enable the debugger, the reloader and then start the server on24*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::2930    $ flask run --no-reload3132In Code33-------3435The alternative way to start the application is through the36:meth:`Flask.run` method.  This will immediately launch a local server37exactly the same way the :command:`flask` script does.3839Example::4041    if __name__ == '__main__':42        app.run()4344This works well for the common case but it does not work well for45development 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).5051It is however still a perfectly valid method for invoking a non automatic52reloading application.