forked from predystopic-dev/calc-be
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
32 lines (23 loc) · 760 Bytes
/
main.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
from contextlib import asynccontextmanager
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
import uvicorn
from apps.calculator.route import router as calculator_router
from constants import SERVER_URL, PORT, ENV
@asynccontextmanager
async def lifespan(app: FastAPI):
yield
app = FastAPI(lifespan=lifespan)
app.add_middleware(
CORSMiddleware,
allow_origins=['*'],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.get('/')
async def root():
return {"message": "Server is running"}
app.include_router(calculator_router, prefix="/calculate", tags=["calculate"])
if __name__ == "__main__":
uvicorn.run("main:app", host=SERVER_URL, port=int(PORT), reload=(ENV == "dev"))