Application object (propeller.Application)
==========================================

Propeller's Application class contains the code that creates the socket server, responds to client connections and dispatches requests to request handlers.

In your main Python file, you need to define an instance of the Application class. A minimal example includes your URL configuration as its first parameter::

    from propeller import Application, RequestHandler

    class HomeHandler(RequestHandler):
        def get(self, request):
            return Response('Hello world')

    a = Application([
        (r'^/', HomeHandler),
    ])


Running your application
------------------------

Starting your application is done by invoking the ``run()`` method on your Application instance::

    if __name__ == '__main__':
        a.run()

Output::

    [2013-02-22 11:29:40,080] * Propeller 0.1.3 listening on 127.0.0.1:8080

Settings
--------

The Application's constructor takes the following arguments:

**urls**

Default: ()

Your application's URL configuration, which should be provided as a list of 2 or 3 element tuples. The first element is the regular expression that would match a URL, the second element is the [request handler](/docs/request-handlers) that will handle the requests for this URL. The third element is optional and contains static arguments that will be passed as keyword arguments to your request handler's methods. An example of this is the `StaticFileHandler </docs/static-file-handler>`_, which takes ``static_path`` as a keyword argument.

**host**

Default: '127.0.0.1'

The IP your application should listen on. To make Propeller listen on all available IPs, use ``0.0.0.0``.

**port**

Default: 8080

The port your application should listen on.

**debug**

Defaut: False

Whether Propeller runs in debug mode. In debug mode, Propeller uses helpful error pages and reloads the web server when it detects code changes. Disable on production.

**tpl_dir**

Default: 'templates'

The template dir where your templates reside, relative to your project root (the directory where your main application file lives).
