Skip to main content

Tiny HTTP router

Project description

tiny-router

PyPI PyPI - Python Version Code style: black license

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 router
  • SimpleRegexRouter: 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)

Uploaded Source

Built Distribution

tiny_router-0.0.8-py3-none-any.whl (6.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page