fastapi-playground
Deploy a FastML Model with FastAPI
Hello_World
Goal: build the first app with FastAPI Source: https://fastapi.tiangolo.com/tutorial/first-steps/ Examples: https://fastapi.tiangolo.com/#example (How to run, async & wait, How to use uvicorn, API docs)
Steps:
- Install FastAPI
pip install fastapi[all]
- Create a main.py file
from fastapi import FastAPI app = FastAPI() @app.get("/") def read_root(): return {"Hello": "World"} @app.get("/items/{item_id}") def read_item(item_id: int, q: str = None): return {"item_id": item_id, "q": q}
- Run the application
uvicorn main:app --reload
- Check the app
http://localhost:8000/
- Check the automatic generated documentation
http://localhost:8000/docs