Router Class

class styrofoam.Router(default_app=None, apps=[])[source]

Adds a WSGI application to the router. The attributes passed to this method are passed to Application.__init__, so these two are the same:

my_router.apps.append(Application(func=f, url='/hi'))
my_router.add_app(func=f, url='/hi')

Application Class

class styrofoam.Application(func, url, modify_urls=True, minify=False)[source]

This class represents a WSGI application. It holds the WSGI handler function of the app, the url prefix that the app is mounted at, and some other configuration options. A Router object holds an array of Application objects, along with the default WSGI application.

  • func – The WSGI handler function (the one with the environ and the start_request arguments)
  • url – The url to mount the application at. It must have a beginning forward slash, but must not have one at the end (e.g. /path/to/app).
  • modify_urls – Whether or not to parse the app’s output and correct urls in it (e.g. in an <a> tag) to go to urls within the one the app is mounted at. For example, an application that is mounted at /oof will have <a href="/no"> replaced to <a href="/oof/no">. It currently has not been implemented yet. When this parameter is set to True (the default), the app’s output will be minified regardless of the minify attribute.