Skip to content
Myr

server.rst

This file

Path

docs/server.rst

50 lines · 1.6 KiB

Last changed by

Merge pull request #1172 from cgar/spellingMarkus Unterwaditzerbefore adoption773ad9b

History of this file

Take it

1.. _server:23Development Server4==================56.. currentmodule:: flask78Starting with Flask 1.0 there are multiple built-in ways to run a9development server.  The best one is the ``flask`` command line utility10but you can also continue using the :meth:`Flask.run` method.1112Command Line13------------1415The ``flask`` command line script (:ref:`cli`) is strongly recommende for16development because it provides a superior reload experience due to how it17loads the application.  The basic usage is like this::1819    $ flask -a my_application --debug run2021This will enable the debugger, the reloader and then start the server on 22*http://localhost:5000/*.2324The individual features of the server can be controlled by passing more25arguments to the ``run`` option.  For instance the reloader can be26disabled::2728    $ flask -a my_application --debug run --no-reload2930In Code31-------3233The alternative way to start the application is through the34:meth:`Flask.run` method.  This will immediately launch a local server35exactly the same way the ``flask`` script does.3637Example::3839    if __name__ == '__main__':40        app.run()4142This works well for the common case but it does not work well for43development which is why from Flask 1.0 onwards the ``flask`` method is44recommended.  The reason for this is that due to how the reload mechanism45works there are some bizarre side-effects (like executing certain code46twice, sometimes crashing without message or dying when a syntax or47import error happens).4849It is however still a perfectly valid method for invoking a non automatic50reloading application.