=========================
Serving WSGI Applications
=========================

There are many ways to serve a WSGI application.  While you're developing it,
you usually don't want to have a full-blown webserver like Apache up and
running, but instead a simple standalone one.  With Python 2.5 and onwards,
there is the `wsgiref`_ server in the standard library.  If you're using older
versions of Python you can download the package from the `Cheeseshop`_.

However, there are some caveats.  Sourcecode won't reload itself when changed,
and each time you kill the server using ``^C`` you get a `KeyboardInterrupt`
error.  While the latter is easy to solve, the first one can be a pain in the
ass in some situations.

Because of that Werkzeug ships a small wrapper over `wsgiref` that spawns the
WSGI application in a subprocess and automatically reloads the application if
a module was changed.

The easiest way is creating a small ``start-myproject.py`` file that runs the
application:

.. sourcecode:: python

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-

    from werkzeug import run_simple
    from myproject import make_app

    app = make_app(...)
    run_simple('localhost', 8080, app, use_reloader=True)

You can also pass it the `extra_files` keyword argument with a list of
additional files (like configuration files) you want to observe.

.. def:: werkzeug.serving.run_simple


.. _wsgiref: http://cheeseshop.python.org/pypi/wsgiref
.. _Cheeseshop: http://pypi.python.org/
