Tiny HTTP router
Project description
tiny-router
Tiny HTTP router.
Usage
from tiny_router import SimpleRouter
router = SimpleRouter()
@router.get("/users/{user_id}")
def get_user(params):
if params.get("user_id") == 1:
return {"id": 1, "name": "Alice"}
route = router.resolve("GET", "/users/{user_id}")
user = route({"user_id": 1})
assert user == {"id": 1, "name": "Alice"}
More examples are in examples/
directory of
repository.
Features
SimpleRouter
: exact-match routerSimpleRegexRouter
: simple regex-based router- Abstract
Router
: user can implement their own routers - Support for type hints
API
Module tiny_router
TODO
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tiny-router-0.0.8.tar.gz
(4.6 kB
view hashes)
Built Distribution
Close
Hashes for tiny_router-0.0.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7db11f3688bba0d032d6754806f52585102765ed7844c6f0b8196c2e94f1da5f |
|
MD5 | d9ff6178a57b88da7168588170af66d2 |
|
BLAKE2b-256 | 480bb10f704d4ab1241f1a36135147453dad104d3244cfcf44634cb5c3f9e774 |