{"id":24738622,"url":"https://github.com/zweifisch/biro","last_synced_at":"2025-06-11T22:34:47.644Z","repository":{"id":14906363,"uuid":"17630314","full_name":"zweifisch/biro","owner":"zweifisch","description":"bidirectional URI routing","archived":false,"fork":false,"pushed_at":"2014-03-19T14:25:25.000Z","size":148,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-02T18:41:52.341Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/zweifisch.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2014-03-11T12:55:26.000Z","updated_at":"2014-03-19T14:25:24.000Z","dependencies_parsed_at":"2022-09-26T20:21:27.031Z","dependency_job_id":null,"html_url":"https://github.com/zweifisch/biro","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zweifisch%2Fbiro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zweifisch%2Fbiro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zweifisch%2Fbiro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zweifisch%2Fbiro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zweifisch","download_url":"https://codeload.github.com/zweifisch/biro/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245006608,"owners_count":20546136,"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":[],"created_at":"2025-01-27T22:55:04.030Z","updated_at":"2025-03-22T18:42:46.089Z","avatar_url":"https://github.com/zweifisch.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# biro\n\nbidirectional URI routing\n\n```python\nfrom biro import get, path_for, match\n\n@get('/article')\ndef list_article():\n    pass\n\n@get('/article/\u003carticle_id\u003e')\ndef show_article():\n    pass\n\npath_for(show_article, article_id=618)  # /article/618\npath_for(list_article, limit=10)  # /article?limit=10\n\nmatch('GET', \"/article/309\")  # (article, {\"article_id\": \"309\"})\nmatch('POST', \"/article/309\")  # (None, None)\n```\n\n## the Router class\n\n```python\nfrom biro import Router\n\nrouter = Router()\nrouter.append('DETELE', '/article/\u003carticle_id\u003e', handler)\n\nrouter.match('PATCH', '/path')\nrouter.path_for(handler, q=val)\n```\n\n## wsgi example\n\n```python\nfrom biro import get, match\n\n@get('/')\ndef home():\n    return 'home'\n\n@get('/hello/\u003cname\u003e')\ndef hello(name):\n    return 'hello %s' % name\n\ndef application(environ, start_response):\n    handler, params = match(environ['REQUEST_METHOD'].upper(),\n                            environ['PATH_INFO'])\n    if handler:\n        status = '200 OK'\n        response = handler(**params)\n    else:\n        status = '404 Not Found'\n        response = 'page not found'\n    start_response(status, [('Content-Type', 'text/html; charset=utf-8')])\n    return [response.encode('utf-8')]\n```\n\nsave it as example.py, then it can be lunched using gunicorn like this:\n\n```\n$ gunicorn example:application\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzweifisch%2Fbiro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzweifisch%2Fbiro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzweifisch%2Fbiro/lists"}