Router middleware for xweb.
Project description
xweb-router
Router middleware for xweb
Usage
from xweb import App from xweb_router import Router app = App() router = Router() nested = Router() app.use(router) @router.use('/') async def middleware(ctx, fn): """Router Middleware""" print('middleware') await fn() @router.post('/') async def home(ctx): ctx.body = "Home" @router.get('/{name}') async def hello(ctx): """URL parameters""" ctx.body = f"Hello {ctx.params.name}" router.use('/post')(nested) @nested.get('/index') async def index(ctx): ctx.body = "Nested Index" if __name__ == '__main__': app.listen(8000)
Nested Router
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
xweb_router-0.1.1.tar.gz
(2.4 kB
view hashes)
Built Distribution
Close
Hashes for xweb_router-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 103981f1b5df4bb08d2f731eccf66b973f5e6df160c86c2bd804c1f5380aa969 |
|
MD5 | d13dbdda20f98d78d22503f7a5007991 |
|
BLAKE2-256 | 9cd8e8fb9446b4f90266b01d8e9a57c1be43fec9cf2514aecdbd124c65fc97f1 |