A WSGI routing apparatus.
Project description
Decorouter is a WSGI routing apparatus that makes it easy to define routes using decorator syntax.
Example:
from decorouter import Router
class MyApplication:
router = Router()
@router.add('/$')
def index(self, environ, start_response):
start_response('200 OK', [('Content-type', 'text/plain')])
return ['Hello, world!']
@router.add('/hello/([^/]+)$')
def index(self, environ, start_response):
args, kwargs = environ['wsgiorg.routing_args']
(name,) = args
start_response('200 OK', [('Content-type', 'text/plain')])
return ['Hello, %s!' % (name,)]
def __call__(self, environ, start_response):
return self.router(environ, start_response)
if __name__ == '__main__':
from wsgiref.simple_server import make_server
make_server('', 8000, MyApplication()).serve_forever()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
decorouter-0.0.2.tar.gz
(3.4 kB
view details)
File details
Details for the file decorouter-0.0.2.tar.gz.
File metadata
- Download URL: decorouter-0.0.2.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
318f77aedc3b04db3e9868c9d20195e8728650eaac27621b3ebb1d9d452067dd
|
|
| MD5 |
55269db194361a756655f9019417c03c
|
|
| BLAKE2b-256 |
97ee40430afdb21012965bd197b3c7ec95444e8ebb84ebb9a4af516596028506
|