-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
32 lines (27 loc) · 1013 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
from fastapi.middleware.cors import CORSMiddleware
from routes import pokemons, trainers, evolve, home
from config import frontend_folder_name
app = FastAPI()
app.mount("/static", StaticFiles(directory=os.path.join(frontend_folder_name, "static")), name="static")
# Add CORS Middleware
origins = [
"http://localhost:3000",
"http://localhost:8000",
"http://127.0.0.1:8000",
"http://localhost:8001",
"http://localhost:8002"
]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(home.router, prefix="", tags=["Home"])
app.include_router(pokemons.router, prefix="/pokemons", tags=["Pokemons endpoint"])
app.include_router(trainers.router, prefix="/trainers",tags=["Trainers endpoint"])
app.include_router(evolve.router, prefix="/evolve",tags=["Evolution endpoint"])