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
from webob import Request
from webob.dec import wsgify
from webdispatch import Dispatcher
from webdispatch.mixins import URLMapperMixin

class MyRequest(Request, URLMapperMixin):
    pass

app = Dispatcher()

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

@wsgify(RequestClass=MyRequest)
def hello(request):
    return "Hello"

app.add_url('home', '/', index)
app.add_url('hello', '/hello', hello)

from wsgiref.simple_server import make_server

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

Contents:

Indices and tables

Project Versions

Table Of Contents

This Page