Welcome to WebDispatch’s documentation!

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from webob import Request
from webob.dec import wsgify
from webdispatch import URLDispatcher
from webdispatch.mixins import URLMapperMixin

class MyRequest(Request, URLMapperMixin):
    pass

app = URLDispatcher()

@wsgify(RequestClass=MyRequest)
def index(request):
    url = request.generate_url("hello", xname="webdispatch")
    return '<a href="%s">Hello</a>' % (url,)

@wsgify(RequestClass=MyRequest)
def hello(request):
    return "Hello %s" % request.urlvars['xname']

app.add_url('home', '/', index)
app.add_url('hello', '/hello/{xname}', hello)

if __name__ == '__main__':
    from wsgiref.simple_server import make_server

    httpd = make_server('0.0.0.0', 8080, app)
    httpd.serve_forever()

Contents:

Indices and tables

Project Versions

Table Of Contents

Next topic

Basic Usage

This Page