🐐
This commit is contained in:
22
backend/main.py
Normal file
22
backend/main.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from card import _get_cards_async
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["http://localhost:5173"], # SvelteKit's default dev port
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
@app.get("/pack/{size}")
|
||||
async def open_pack(size: int = 10):
|
||||
cards = await _get_cards_async(size)
|
||||
return [
|
||||
{**card._asdict(),
|
||||
"card_type": card.card_type.name,
|
||||
"card_rarity": card.card_rarity.name}
|
||||
for card in cards
|
||||
]
|
||||
Reference in New Issue
Block a user