2024-07-24 22:53:56 +02:00
|
|
|
from typing import Union
|
|
|
|
|
from fastapi import FastAPI
|
|
|
|
|
|
2024-07-25 17:53:59 +02:00
|
|
|
from classes.boardgame import BoardGame, BoardGameExpansion
|
2024-07-26 10:46:46 +02:00
|
|
|
from bgg_connection import get_boardgame
|
2024-07-25 17:53:59 +02:00
|
|
|
|
2024-07-24 22:53:56 +02:00
|
|
|
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):
|
2024-07-25 17:53:59 +02:00
|
|
|
return {"item_id": item_id, "q": q}
|
|
|
|
|
|
2024-07-25 19:38:20 +02:00
|
|
|
@app.get("/boardgame/{boardgame_id}", response_model=BoardGame)
|
|
|
|
|
def get_boardgame_by_id(boardgame_id: int):
|
2024-07-26 12:04:44 +02:00
|
|
|
requested_boardgame: BoardGame = get_boardgame(boardgame_id)
|
|
|
|
|
return requested_boardgame
|