{"id":16418487,"url":"https://github.com/nitely/kua","last_synced_at":"2025-03-21T03:32:36.337Z","repository":{"id":10734062,"uuid":"66780252","full_name":"nitely/kua","owner":"nitely","description":":zap: Lightning fast URL routing in Python (trie router)","archived":false,"fork":false,"pushed_at":"2022-07-16T05:11:01.000Z","size":31,"stargazers_count":23,"open_issues_count":4,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-12T07:14:17.021Z","etag":null,"topics":["python","router","trie"],"latest_commit_sha":null,"homepage":"http://kua.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nitely.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-28T17:03:53.000Z","updated_at":"2024-04-02T10:50:29.000Z","dependencies_parsed_at":"2022-09-04T16:22:18.808Z","dependency_job_id":null,"html_url":"https://github.com/nitely/kua","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitely%2Fkua","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitely%2Fkua/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitely%2Fkua/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitely%2Fkua/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nitely","download_url":"https://codeload.github.com/nitely/kua/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221811374,"owners_count":16884305,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","router","trie"],"created_at":"2024-10-11T07:14:15.992Z","updated_at":"2024-10-28T09:16:22.094Z","avatar_url":"https://github.com/nitely.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kua\n\n[![Build Status](https://img.shields.io/travis/nitely/kua.svg?style=flat-square)](https://travis-ci.org/nitely/kua)\n[![Coverage Status](https://img.shields.io/coveralls/nitely/kua.svg?style=flat-square)](https://coveralls.io/r/nitely/kua)\n[![pypi](https://img.shields.io/pypi/v/kua.svg?style=flat-square)](https://pypi.python.org/pypi/kua)\n[![licence](https://img.shields.io/pypi/l/kua.svg?style=flat-square)](https://raw.githubusercontent.com/nitely/kua/master/LICENSE)\n\nLightning fast URL routing in Python.\n\nkua is a [Trie](https://en.wikipedia.org/wiki/Trie)-like based router.\nIt scales better than regex based routers and due to this it's usually faster.\n\nIt's pretty bare bones and it's meant to be used in more feature-rich routers.\n\n\n## Compatibility\n\n* Python 3.5\n\n\n## Install\n\n```\n$ pip install kua\n```\n\n\n## Usage\n\n```python\nimport kua\n\nroutes = kua.Routes()\nroutes.add('api/:foo', {'GET': my_get_controller})\nroute = routes.match('api/hello-world')\nroute.params\n# {'foo': 'hello-world'}\nroute.anything\n# {'GET': my_get_controller}\n```\n\n-\u003e [More](http://kua.readthedocs.io/en/latest/api.html#kua.routes.Routes)\n\n\n# Docs\n\n[Read The Docs](http://kua.readthedocs.io)\n\n\n## Tests\n\n```\n$ make test\n```\n\n\n# Backtracking\n\nBacktracking means kua will have to try more than one path to match the URL.\n\nThis *may* hurt performance, depending how much backtracking is involved,\nusually you should not worry about it, though.\n\nThis reduces to not placing two variables next to each other and not placing\na variable where there is a static one in a similar pattern.\n\nHere are some examples of good and bad schemas:\n\n```python\n# bad\nroutes.add(':var', ...)  # clashes with pretty much every pattern\n\n# still bad\nroutes.add(':var1/:var2', ...)\n\n# bad\nroutes.add(':var1/foo', ...)\n\n# still bad\nroutes.add(':var1/:var2/foo', ...)\n\n# bad\nroutes.add('api/:var1', ...)\nroutes.add('api/foo', ...)\n\n# still bad\nroutes.add('api/:var1/:var2', ...)\nroutes.add('api/foo', ...)\n\n# still bad\nroutes.add('api/:var1/foo', ...)\nroutes.add('api/foo', ...)\n\n# good\nroutes.add('api', ...)\nroutes.add('api/:var', ...)\nroutes.add('api/:var/foo', ...)\nroutes.add('api/:var/bar', ...)\nroutes.add('api/:var/foo/:var2', ...)\nroutes.add('api/:var/bar/:var2', ...)\n\n# good\nroutes.add('topics', ...)\nroutes.add('topics/:var', ...)\nroutes.add('authors', ...)\nroutes.add('authors/:var', ...)\n\n# good\nroutes.add('shelf', ...)\nroutes.add('shelf/books', ...)\nroutes.add('shelf/books/:var', ...)\n\n# good\nroutes.add('books/all', ...)\nroutes.add('books/removed', ...)\nroutes.add('books/pending', ...)\n```\n\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnitely%2Fkua","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnitely%2Fkua","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnitely%2Fkua/lists"}