python-warouter
Warouter is a simple routing wrapper around webapp2.
Installing
$ pip install warouter
Usage
Warouter provides url inheritance for handlers and a convenient uri_for function which can be called with a handler, instead of a string name.
A WSGIApplication mixin is provided which can handle a list of url decorator handlers.
Example:
>>> import warouter
>>> import webapp2
>>>
>>> @warouter.url('/')
... class RootHandler(webapp2.RequestHandler):
... def get(self):
... self.response.write('root')
...
>>> @warouter.url('/child/<child_param:([a-z]+)>')
... class ChildHandler(RootHandler):
... def get(self, child_param):
... self.response.write(child_param)
... def put(self, child_param):
... pass
...
>>> @warouter.url('/grandchild/<grandchild_param:([a-z]+)>')
... class GrandChildHandler(ChildHandler):
... def get(self, child_param, grandchild_param):
... self.response.write('\n'.join([child_param, grandchild_param]))
... def post(self, child_param, grandchild_param):
... self.response.write(warouter.uri_for(ChildHandler,
... child_param=child_param))
...
>>> assert RootHandler.url == '/'
>>> assert ChildHandler.url == '/child/<child_param:([a-z]+)>'
>>> assert GrandChildHandler.url == (
... '/child/<child_param:([a-z]+)>/grandchild/<grandchild_param:([a-z]+)>')
>>> assert GrandChildHandler.put is None
>>>
>>> app = warouter.WSGIApplication([
... RootHandler,
... ChildHandler,
... GrandChildHandler
... ])
>>>
>>> if __name__ == '__main__':
... from paste import httpserver
... httpserver.serve(app, port='8080')
...
>>>
The above example requires Paste, which can be installed using:
$ pip install paste
License
MIT
Metadata
Release files for warouter 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| warouter-0.1.1-py27-none-any.whl | Python 2.7 | none | any | Details for warouter-0.1.1-py27-none-any.whl |
Release files / warouter-0.1.1-py27-none-any.whl
| Download URL | warouter-0.1.1-py27-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 2.7 |
|
SHA-256 checksum How to use checksums |
e8c3377a44360dc9716e26ce65d7e85336ac5d6242e703967ff74095f927271a
|
|
BLAKE2b-256 checksum How to use checksums |
5b0ecac9e048e6cb2e17d6bb4b6f379108d7a1da787c74b1cbd54241bfd5756d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for warouter 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.