Compare commits
8 commits
main
...
creating_b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80535cb27c | ||
|
|
f8cc27a037 | ||
|
|
4f3370efef | ||
|
|
85e9b18039 | ||
|
|
64a335ac98 | ||
|
|
57cebaaf02 | ||
|
|
b90aaad637 | ||
|
|
4e4fb04b88 |
3 changed files with 39 additions and 2 deletions
|
|
@ -1,4 +1,2 @@
|
||||||
# bgg_api
|
# bgg_api
|
||||||
|
|
||||||
An API implementation that will be used by my own board game website.
|
|
||||||
The plan is for this API to be used by a single person who wants their board game collection to be cached so that retrieval is much faster.
|
|
||||||
|
|
|
||||||
19
classes/boardgame.py
Normal file
19
classes/boardgame.py
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
from pydantic import BaseModel, HttpUrl
|
||||||
|
|
||||||
|
class BoardGame(BaseModel):
|
||||||
|
id: int
|
||||||
|
name: str
|
||||||
|
description: str
|
||||||
|
image_url = HttpUrl
|
||||||
|
thumbnail_url = HttpUrl
|
||||||
|
year_published: int
|
||||||
|
min_players: int
|
||||||
|
max_players: int
|
||||||
|
min_playing_time: int
|
||||||
|
max_playing_time: int
|
||||||
|
min_age: int
|
||||||
|
all_expansion_ids: list[int]
|
||||||
|
|
||||||
|
|
||||||
|
class BoardGameExpansion(BoardGame):
|
||||||
|
pass
|
||||||
20
main.py
Normal file
20
main.py
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
from typing import Union
|
||||||
|
from fastapi import FastAPI
|
||||||
|
|
||||||
|
from classes.boardgame import BoardGame, BoardGameExpansion
|
||||||
|
|
||||||
|
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):
|
||||||
|
pass
|
||||||
Loading…
Reference in a new issue