{"id":26614580,"url":"https://github.com/j03-dev/oxapy","last_synced_at":"2026-01-19T17:01:05.164Z","repository":{"id":277908984,"uuid":"933884268","full_name":"j03-dev/oxapy","owner":"j03-dev","description":"OxAPY is python HTTP server library build in Rust","archived":false,"fork":false,"pushed_at":"2025-06-14T13:39:13.000Z","size":563,"stargazers_count":7,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-14T14:33:45.560Z","etag":null,"topics":["fast","fastapi","http-server","library","next-fastapi","python","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/j03-dev.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-02-16T22:29:02.000Z","updated_at":"2025-06-14T13:39:16.000Z","dependencies_parsed_at":"2025-03-24T05:34:46.895Z","dependency_job_id":"2d6f4535-9cb4-47a2-903b-6555a7a96a4e","html_url":"https://github.com/j03-dev/oxapy","commit_stats":null,"previous_names":["j03-dev/oxhttp","j03-dev/oxapy"],"tags_count":49,"template":false,"template_full_name":null,"purl":"pkg:github/j03-dev/oxapy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j03-dev%2Foxapy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j03-dev%2Foxapy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j03-dev%2Foxapy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j03-dev%2Foxapy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/j03-dev","download_url":"https://codeload.github.com/j03-dev/oxapy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/j03-dev%2Foxapy/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260576381,"owners_count":23030582,"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":["fast","fastapi","http-server","library","next-fastapi","python","rust"],"created_at":"2025-03-24T05:34:27.454Z","updated_at":"2026-01-19T17:01:05.157Z","avatar_url":"https://github.com/j03-dev.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OxAPY\n\n\u003cdiv align=\"center\"\u003e\n \u003ch4\u003e\n    \u003ca href=\"https://github.com/j03-dev/oxapy/issues/\"\u003eReport Bug\u003c/a\u003e\n \u003c/h4\u003e\n\n\u003cp\u003e\n  \u003cb\u003eOxAPY\u003c/b\u003e is Python HTTP server library build in Rust - a fast, safe and featureementation.\n\u003c/p\u003e\n\n\u003ca href='https://github.com/j03-dev/oxapy/#'\u003e\u003cimg src='https://img.shields.io/badge/version-0.8.0-%23b7410e'/\u003e\u003c/a\u003e\n\u003ca href=\"https://pepy.tech/projects/oxapy\"\u003e\u003cimg src=\"https://static.pepy.tech/badge/oxapy\" alt=\"PyPI Downloads\"\u003e\u003c/a\u003e\n\n\u003cp\u003e\n \u003ca href='https://pypi.org/project/oxapy/'\u003e \u003cimg src='https://img.shields.io/pypi/v/oxapy?style=for-the-badge'/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp\u003e\n   \u003cstrong\u003e Show your support\u003c/strong\u003e  \u003cem\u003e by giving a star 🌟 if this project helped you! \u003c/em\u003e\n\u003c/p\u003e\n\n\u003cp\u003e\n  \u003ca href=\"https://bench-n9zz.onrender.com/bench/benchmark_rps.png\"\u003e\u003cimg src=\"https://bench-n9zz.onrender.com/bench/benchmark_rps.png\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003c/div\u003e\n\n## Features\n\n- Routing with path parameters\n- Middleware support\n- Static file serving\n- Application state management\n- Request/Response handling\n- Query string parsing\n- Router base path prefixing\n\n## Basic Example\n\n```python\nfrom oxapy import HttpServer, Router, Status, Response, get\n\n@get(\"/\")\ndef welcome(request):\n    return Response(\"Welcome to OxAPY!\", content_type=\"text/plain\")\n\n@get(\"/hello/{name}\")\ndef hello(request, name):\n    return Response({\"message\": f\"Hello, {name}!\"})\n\ndef main():\n    (\n        HttpServer((\"127.0.0.1\", 5555))\n        .attach(\n            Router()\n            .route(welcome)\n            .route(hello)\n        )\n        .run()\n    )\n\nif __name__ == \"__main__\":\n    main()\n```\n\n## Async Example\n\n```python\nfrom oxapy import HttpServer, Router, get\n\nimport asyncio\n\n@get(\"/\")\nasync def home(request):\n    # Asynchronous operations are allowed here\n    data = await fetch_data_from_database()  \n    return \"Hello, World!\"\n\nasync def main():\n    await (\n        HttpServer((\"127.0.0.1\", 8000))\n        .attach(\n            Router().route(home)\n        )\n        .async_mode()\n        .run()\n    )\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n\n## Middleware Example\n\nOxAPY's middleware system is designed to be flexible and powerful. Middleware is applied to all routes within the same **scope**. You can use the `.scope()` method to create new scopes, allowing you to group routes with different middleware. This allows for building complex routing structures where different sets of middleware apply to different groups of routes.\n\n### Best Practices\n\n- **Order Matters**: Middleware is executed in the order it is defined within a scope.\n- **Scoping**: Use `.scope()` to create logical separation between groups of routes and their middleware. For example, you can have one scope for public endpoints and another for authenticated endpoints.\n- **Clarity**: Be mindful that middleware applies to all routes defined in the current scope, both before and after the middleware is added.\n\n```python\nfrom oxapy import Status, Router, get, HttpServer\n\ndef log_middleware(request, next, **kwargs):\n    print(f\"Request: {request.method} {request.uri}\")\n    return next(request, **kwargs)\n\ndef auth_middleware(request, next, **kwargs):\n    if \"authorization\" not in request.headers:\n        return Status.UNAUTHORIZED\n    return next(request, **kwargs)\n\n@get(\"/public\")\ndef public(request):\n    return \"This is a public route.\"\n\n@get(\"/protected\")\ndef protected(request):\n    return \"This is a protected route.\"\n\ndef main():\n    (\n        HttpServer((\"127.0.0.1\", 5555))\n        .attach(\n            Router()\n            # First scope: public routes with logging\n            .route(public)\n            .middleware(log_middleware)\n\n            # Second scope: protected routes with logging and authentication\n            .scope()\n            .route(protected)\n            .middleware(log_middleware)\n            .middleware(auth_middleware)\n        )\n        .run()\n    )\n\nif __name__ == \"__main__\":\n    main()\n```\n\n## Static Files\n\n```python\nfrom oxapy import HttpServer, Router, static_file\n\ndef main():\n    (\n        HttpServer((\"127.0.0.1\", 5555))\n        .attach(\n            Router().route(static_file(\"/static\", \"./static\"))\n        )\n        .run()\n    )\n\nif __name__ == \"__main__\":\n    main()\n```\n\n## Application State\n\n```python\nfrom oxapy import HttpServer, Router, get\n\nclass AppState:\n    def __init__(self):\n        self.counter = 0\n\n@get(\"/count\")\ndef handler(request):\n    app_data = request.app_data\n    app_data.counter += 1\n    return {\"count\": app_data.counter}\n\ndef main():\n    (\n        HttpServer((\"127.0.0.1\", 5555))\n        .app_data(AppState())\n        .attach(\n            Router().route(handler)\n        )\n        .run()\n    )\n\nif __name__ == \"__main__\":\n    main()\n```\n\n## Router with Base Path\n\nYou can set a base path for a router, which will be prepended to all routes defined in it. This is useful for versioning APIs.\n\n```python\nfrom oxapy import HttpServer, Router, get\n\n@get(\"/users\")\ndef get_users(request):\n    return [{\"id\": 1, \"name\": \"user1\"}]\n\ndef main():\n    (\n        HttpServer((\"127.0.0.1\", 5555))\n        .attach(\n            Router(\"/api/v1\").route(get_users)\n        )\n        .run()\n    )\n\nif __name__ == \"__main__\":\n    main()\n\n# You can now access the endpoint at http://127.0.0.1:5555/api/v1/users\n```\n\nTodo:\n\n- [x] Handler\n- [x] HttpResponse\n- [x] Routing\n- [x] use tokio::net::Listener\n- [x] middleware\n- [x] app data\n- [x] pass request in handler\n- [x] serve static file\n- [x] templating\n- [x] query uri\n- [ ] security submodule\n    - [x] jwt\n    - [ ] bcrypt\n- [ ] websocket\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fj03-dev%2Foxapy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fj03-dev%2Foxapy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fj03-dev%2Foxapy/lists"}