Lesson 4 of 5 · 2 min
FastAPI: put it online
FastAPI uses the same type hints to validate requests and to write documentation for you.
# Run on your computer: pip install fastapi uvicorn
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
class Ask(BaseModel):
question: str
@app.post("/ask")
def ask(body: Ask):
return {"answer": f"You asked: {body.question}"}
# uvicorn main:app --reload, then open /docs