bgg_api/main.py

28 lines
879 B
Python
Raw Normal View History

2024-07-24 22:53:56 +02:00
from typing import Union
from fastapi import FastAPI
from classes.boardgame import BoardGame, BoardGameExpansion
2024-08-01 10:35:51 +02:00
from bgg_connection import get_boardgame, get_user_owned_collection, get_user_wishlist_collection
2024-07-24 22:53:56 +02:00
app = FastAPI()
@app.get("/")
def read_root():
return {"Hello": "World"}
2024-07-25 19:38:20 +02:00
@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()
2024-08-01 10:35:51 +02:00
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