Skip to content

Commit d87886c

Browse files
github-actions[bot]FAQ Botalexeygrigorev
authored
[FAQ Bot] NEW: How to run a FastAPI app for serving a Python pickle-based model and res (#34)
* NEW: How to run a FastAPI app for serving a Python pickle-based model and res * Update 063_69e5f9cbf8_fastapi-deploy-pickle-model.md --------- Co-authored-by: FAQ Bot <faq-bot@datatalks.club> Co-authored-by: Alexey Grigorev <alexeygrigorev@users.noreply.github.com>
1 parent 16b19bd commit d87886c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
id: 69e5f9cbf8
3+
question: How to run a FastAPI app for serving a Python pickle-based model and resolve
4+
common startup errors (uvicorn/fastapi) when deploying on a local port?
5+
sort_order: 63
6+
---
7+
8+
The error described is typically due to using an incorrect command to start the FastAPI server. Use uvicorn to run the FastAPI app and specify the module and app object correctly. If your script is named `your_script_fastapi_app.py` and defines a FastAPI instance `app`, start the server with:
9+
10+
```bash
11+
uvicorn your_script_fastapi_app:app --host 0.0.0.0 --port 9696 --reload
12+
```
13+
14+
Notes:
15+
- Ensure the script defines the app: `from fastapi import FastAPI; app = FastAPI()`.
16+
- The syntax `uvicorn module:app` is required
17+
- If you still get errors, verify the module imports succeed (no syntax/runtime errors) and that the port is not already in use.
18+
- You can test the API by curling `http://localhost:9696/` or hitting your defined endpoints.

0 commit comments

Comments
 (0)