2024-08-04 08:43:04 +02:00
|
|
|
from fastapi import FastAPI
|
2024-08-04 10:06:07 +02:00
|
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
|
|
2024-08-04 09:01:17 +02:00
|
|
|
from src.classes import product_classes
|
|
|
|
|
from src import data_connection
|
2024-08-04 08:43:04 +02:00
|
|
|
|
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
2024-08-04 10:06:07 +02:00
|
|
|
origins = [
|
|
|
|
|
"*" #Will become something like 'shop.yarnecoppens.com'
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
app.add_middleware(
|
|
|
|
|
CORSMiddleware,
|
|
|
|
|
allow_origins=origins,
|
|
|
|
|
allow_credentials=False,
|
|
|
|
|
allow_methods=["*"],
|
|
|
|
|
allow_headers=["*"],
|
|
|
|
|
)
|
|
|
|
|
|
2024-08-04 08:43:04 +02:00
|
|
|
@app.get("/")
|
|
|
|
|
def read_root():
|
|
|
|
|
return {"Hello": "World"}
|
|
|
|
|
|
2024-08-04 09:01:17 +02:00
|
|
|
@app.get("/products", response_model=list[product_classes.Product])
|
2024-08-04 08:47:49 +02:00
|
|
|
def get_all_products():
|
2024-08-04 09:01:17 +02:00
|
|
|
return data_connection.get_all_products()
|
2024-08-04 08:47:49 +02:00
|
|
|
|
|
|
|
|
# @app.get("/boardgames/{boardgame_id}", response_model=boardgame_classes.BoardGame)
|
2024-08-04 08:43:04 +02:00
|
|
|
# def get_boardgame_by_id(boardgame_id: int):
|
|
|
|
|
# requested_boardgame: boardgame_classes.BoardGame = data_connection.get_boardgame(boardgame_id)
|
|
|
|
|
# return requested_boardgame
|