{"id":17363202,"url":"https://github.com/novasush/fastapi-nginx-unit","last_synced_at":"2025-04-14T17:07:41.308Z","repository":{"id":129487639,"uuid":"345065191","full_name":"novasush/fastapi-nginx-unit","owner":"novasush","description":"Deploying an Asynchronous FastAPI on NGINX Unit","archived":false,"fork":false,"pushed_at":"2021-03-14T10:14:23.000Z","size":4,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-14T17:07:39.362Z","etag":null,"topics":["docker","docker-compose","fastapi","nginx-unit","openapi","python","python3"],"latest_commit_sha":null,"homepage":"","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/novasush.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":"2021-03-06T10:25:52.000Z","updated_at":"2025-04-07T22:34:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"feef65da-8196-4bfa-8ac2-e090465803ca","html_url":"https://github.com/novasush/fastapi-nginx-unit","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/novasush%2Ffastapi-nginx-unit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/novasush%2Ffastapi-nginx-unit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/novasush%2Ffastapi-nginx-unit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/novasush%2Ffastapi-nginx-unit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/novasush","download_url":"https://codeload.github.com/novasush/fastapi-nginx-unit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248923765,"owners_count":21183953,"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":["docker","docker-compose","fastapi","nginx-unit","openapi","python","python3"],"created_at":"2024-10-15T19:53:08.843Z","updated_at":"2025-04-14T17:07:41.302Z","avatar_url":"https://github.com/novasush.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fastapi-nginx-unit\nA simple 'hello world' app of FastAPI running on NGINX Unit App server using ASGI.\n\n## Running on Docker\n```bash\ndocker-compose up --build\n```\nAfter that you can test using `curl` command.\n```bash\ncurl http://localhost\n```\n\n## Running test cases (docker)\n```bash\n# Run the docker server if you haven't started it yet then run below command for executing test cases\ndocker-compose exec api pytest /fastapi\n```\n\n## Running from terminal\n1. Create venv in your project directory and install fastapi\n```bash\n$ python3 -m venv apienv\n$ source apienv/bin/activate\n(venv)$ pip install --upgrade pip\n(venv)$ pip install -r requirements.txt\n$ deactivate\n```\n2. Run the following command for each directory containing app code or data so Unit can access it:\n```bash\n(venv)$ sudo chown -R unit:unit /path/to/app/\n```\n3. Create a JSON configuration file containing information about application.\n```json\n// config.json\n{\n    \"listeners\": {\n        \"*:80\": {\n            \"pass\": \"applications/fastapi\"\n        }\n    },\n\n    \"applications\": {\n        \"fastapi\": {\n            \"type\": \"python 3.x\",\n            \"path\": \"/path/to/app/\",\n            \"home\": \"/path/to/app/venv/\",\n            \"module\": \"asgi\",\n            \"callable\": \"app\"\n        }\n    }\n}\n```\n4. Run the server\n```bash\n(venv)$ unitd\n```\n5. Push the configurations json file on server\n```bash\n(venv)$ sudo curl -X PUT --data-binary @config.json --unix-socket \\\n       /path/to/control.unit.sock http://localhost/config/\n```\n6. Testing (terminal)\n```bash\n(venv)$ pytest .\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnovasush%2Ffastapi-nginx-unit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnovasush%2Ffastapi-nginx-unit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnovasush%2Ffastapi-nginx-unit/lists"}