Enabled ability to retrieve all products
This commit is contained in:
parent
c0e0f73aff
commit
4694556073
3 changed files with 12 additions and 3 deletions
8
src/data_connection.py
Normal file
8
src/data_connection.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
from src.classes import product_classes
|
||||
|
||||
bubble_tea = product_classes.Product(name="Bubble Tea", price=5.0)
|
||||
|
||||
product_list = [bubble_tea]
|
||||
|
||||
def get_all_products() -> list[product_classes.Product]:
|
||||
return product_list
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
from fastapi import FastAPI
|
||||
from classes import product_classes
|
||||
from src.classes import product_classes
|
||||
from src import data_connection
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
|
@ -7,9 +8,9 @@ app = FastAPI()
|
|||
def read_root():
|
||||
return {"Hello": "World"}
|
||||
|
||||
@app.get("/products", response_model=product_classes.Product)
|
||||
@app.get("/products", response_model=list[product_classes.Product])
|
||||
def get_all_products():
|
||||
|
||||
return data_connection.get_all_products()
|
||||
|
||||
# @app.get("/boardgames/{boardgame_id}", response_model=boardgame_classes.BoardGame)
|
||||
# def get_boardgame_by_id(boardgame_id: int):
|
||||
|
|
|
|||
Loading…
Reference in a new issue