bgg_api/main.py
2024-08-01 11:59:40 +02:00

28 lines
No EOL
879 B
Python

from typing import Union
from fastapi import FastAPI
from classes.boardgame import BoardGame, BoardGameExpansion
from bgg_connection import get_boardgame, get_user_owned_collection, get_user_wishlist_collection
app = FastAPI()
@app.get("/")
def read_root():
return {"Hello": "World"}
@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
@app.get("/wishlist", response_model=list[BoardGame])
def get_wishlist_collection():
requested_collection: list[BoardGame] = get_user_wishlist_collection()
return requested_collection