Skip to content

Instantly share code, notes, and snippets.

@leriaetnasta
Last active February 7, 2025 10:54
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
class Starship(BaseModel):
id: str
name: str
price: float
discount: float | None
@app.post("/addStarship")
async def add_starship(starship: Starship):
return {
"starship_id": starship.id,
"starship": starship
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment