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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file tiny-router-0.0.8.tar.gz.

File metadata

  • Download URL: tiny-router-0.0.8.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/2.7.12 Darwin/20.2.0

File hashes

Hashes for tiny-router-0.0.8.tar.gz
Algorithm Hash digest
SHA256 d9daa09fc62186b2aefc995e2bf39d342457fc0e679a987e56f40f39749d05b4
MD5 264f5c7b93a34e77c9213f65b54b9ccf
BLAKE2b-256 5f1a9b7e4e06202c4fb22a93405c13ab52197c9981fdbe3d426fc0e4e272ef67

See more details on using hashes here.

File details

Details for the file tiny_router-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: tiny_router-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/2.7.12 Darwin/20.2.0

File hashes

Hashes for tiny_router-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 7db11f3688bba0d032d6754806f52585102765ed7844c6f0b8196c2e94f1da5f
MD5 d9ff6178a57b88da7168588170af66d2
BLAKE2b-256 480bb10f704d4ab1241f1a36135147453dad104d3244cfcf44634cb5c3f9e774

See more details on using hashes here.

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