-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
35 lines (28 loc) · 1.21 KB
/
main.py
File metadata and controls
35 lines (28 loc) · 1.21 KB
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
33
34
35
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
# Import your routers
from api.routes_v1 import csv_handler_v1
from api.routes_v1 import map_handler_v1
from api.routes_v1 import route_handler_v1
from api.routes_v2 import csv_handler_v2
from api.routes_v2 import map_handler_v2
from api.routes_v2 import route_handler_v2
app = FastAPI()
# Set up CORS (allow all origins for local dev; adjust for production)
app.add_middleware(
CORSMiddleware,
allow_origins=["http://localhost:5173"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Include routers with a prefix
app.include_router(csv_handler_v1.router, prefix="/api/v1", tags=["CSV Handler"])
app.include_router(map_handler_v1.router, prefix="/api/v1", tags=["Map Handler"])
app.include_router(route_handler_v1.router, prefix="/api/v1", tags=["Route Handler"])
app.include_router(csv_handler_v2.router, prefix="/api/v2", tags=["CSV Handler"])
app.include_router(map_handler_v2.router, prefix="/api/v2", tags=["Map Handler"])
app.include_router(route_handler_v2.router, prefix="/api/v2", tags=["Route Handler"])
@app.get("/")
async def root():
return {"message": "Welcome to the FastAPI CSV handler!"}