from typing import Union from fastapi import FastAPI from classes.boardgame import BoardGame, BoardGameExpansion from bgg_connection import get_boardgame, get_user_owned_collection app = FastAPI() @app.get("/") def read_root(): return {"Hello": "World"} @app.get("/items/{item_id}") def read_item(item_id: int, q: Union[str, None] = None): return {"item_id": item_id, "q": q} @app.get("/boardgame/{boardgame_id}", response_model=BoardGame) def get_boardgame_by_id(boardgame_id: int): requested_boardgame: BoardGame = get_boardgame(boardgame_id) return requested_boardgame @app.get("/collection", response_model=list[BoardGame]) def get_owned_collection(): requested_collection: list[BoardGame] = get_user_owned_collection() return requested_collection