urlrelay /

Filename Size Date modified Message
38 B
- hgignore
896 B
- up
3.5 KB
- update
12.5 KB
- update
24.6 KB
- logo

Simple URL dispatcher that passes HTTP requests to a WSGI application based on a matching regular expression and an optional HTTP request method.

Usage example:

import urlrelay

# Simple URL to application mapping
def index(environ, start_response):
   start_response('200 OK', [('Content-type', 'text/plain')])
   return ['Home Page']

# "RESTful" URL to application mapping
@urlrelay.url('^/hello_world$', 'GET')
def hello_world(environ, start_response):
    start_response('200 OK', [('Content-type', 'text/plain')])
    return ['Hello World']

# URL to on-disk application mapping
 urlrelay.register('^/ondisk$', 'module.on_disk')

if __name__ == '__main__':
    from wsgiref.simple_server import make_server
    http = make_server('', 8080, urlrelay.URLRelay())