Creating a virtual environment
python3 -m venv venv
Activating the virtual environment
source venv/bin/activate
pip install -r requirements.txt
from fastapi import FastAPI
app = FastAPI()
@app.get("/", tags=["posts"])
def list_all_posts():
return [{ "title": "My first post", id: 1 }, { "title": "My second post", id: 2 }]
To run:
uvicorn main:app --reload
Jinja2 for HTML templating