33 lines
No EOL
1.1 KiB
Python
33 lines
No EOL
1.1 KiB
Python
from typing import Union
|
|
from fastapi import FastAPI
|
|
|
|
from classes.boardgame import BoardGame, BoardGameExpansion, CollectionBoardGame, CollectionBoardGameExpansion, WishlistBoardGame
|
|
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("/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[CollectionBoardGame])
|
|
def get_owned_collection():
|
|
requested_collection: list[CollectionBoardGame] = get_user_owned_collection()
|
|
return requested_collection
|
|
|
|
|
|
@app.get("/wishlist", response_model=list[WishlistBoardGame])
|
|
def get_wishlist_collection():
|
|
requested_collection: list[WishlistBoardGame] = get_user_wishlist_collection()
|
|
return requested_collection |