Reference¶
Router Class¶
-
class
styrofoam.
Router
(default_app=None, apps=None)[source]¶ This implements the main WSGI app and is the central object. It holds
Application
objects and can be called as a WSGI app.Parameters: - default_app – The default app that is mounted at
'/'
(technically it’s mounted at''
). This must be a function, not anApplication
object. - apps – A list of
Application
objects that will be used as the initial value of theapps
property. A tuple should not be used. Default value is an empty list.
- default_app – The default app that is mounted at
Application Class¶
-
class
styrofoam.
Application
(func, url, modify_urls=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 ofApplication
objects, along with the default WSGI application.Parameters: - func – The WSGI handler function (the one with the
environ
and thestart_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 supports HTTP headers and HTML.
- func – The WSGI handler function (the one with the