Django like WSGI router
Project description
Django-like WSGI router.
from router.core import router
# Define a controller
def hello(request, name, template='Hello %s'):
return template % name
# Register routes
router.add(r'^/hello/(?P<name>[\w_-]+)/$', hello)
router.add(r'^/hello/my/name/is/(?P<name>[\w_-]+)/$', hello, template='Hello my name is %s', name='hello_my_name_is')
# Serve WSGI application
from wsgiref.simple_server import make_server
server = make_server('localhost', 8000, router)
server.serve_forever()
# Reverse controller URL
router.reverse(hello, name='Vincent') # /hello/Vincent/
router.reverse('hello_my_name_is', name='Vincent') # /hello/my/name/is/Vincent/
from router.core import router
# Define a controller
def hello(request, name, template='Hello %s'):
return template % name
# Register routes
router.add(r'^/hello/(?P<name>[\w_-]+)/$', hello)
router.add(r'^/hello/my/name/is/(?P<name>[\w_-]+)/$', hello, template='Hello my name is %s', name='hello_my_name_is')
# Serve WSGI application
from wsgiref.simple_server import make_server
server = make_server('localhost', 8000, router)
server.serve_forever()
# Reverse controller URL
router.reverse(hello, name='Vincent') # /hello/Vincent/
router.reverse('hello_my_name_is', name='Vincent') # /hello/my/name/is/Vincent/
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
platypus-router-0.1.2.tar.gz
(4.1 kB
view details)
File details
Details for the file platypus-router-0.1.2.tar.gz
.
File metadata
- Download URL: platypus-router-0.1.2.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7950aa25d1e049be2af38218e84fe5f14ee0feaf8fd7407eb63c9033b0697bc6 |
|
MD5 | bca9fffc75355dd065a7ce0ee7b155c7 |
|
BLAKE2b-256 | 15d8ceaf1c897805a17730b0677d3bdd4483dcad3a5211ed8641532d3d4b7b68 |