from fastapi import FastAPI, HTTPException from pydantic import BaseModel, Field app = FastAPI(title="Original Show API") class Note(BaseModel): title: str = Field(min_length=1, max_length=120) notes: dict[int, Note] = {} @app.post("/notes/{note_id}") def put_note(note_id: int, note: Note): notes[note_id] = note return {"id": note_id, **note.model_dump()} @app.get("/notes/{note_id}") def get_note(note_id: int): if note_id not in notes: raise HTTPException(404, "note not found") return {"id": note_id, **notes[note_id].model_dump()}