websoft9/appmanage/main.py

34 lines
871 B
Python
Raw Normal View History

2023-03-15 17:55:05 +08:00
from api.utils.common_log import myLogger
2023-02-21 14:21:53 +08:00
import api.v1.api as api_router_v1
import uvicorn
from fastapi import FastAPI
2023-03-14 17:33:06 +08:00
from fastapi.middleware.cors import CORSMiddleware
2023-03-16 15:16:12 +08:00
from fastapi.staticfiles import StaticFiles
2023-02-21 14:21:53 +08:00
2023-03-15 17:55:05 +08:00
myLogger.info_logger("Starting server")
2023-02-21 14:21:53 +08:00
def get_app():
app = FastAPI()
2023-03-16 10:05:02 +08:00
origins = [
"http://localhost",
"http://localhost:3000",
"http://localhost:3001",
"http://localhost:3002",
]
2023-03-14 17:33:06 +08:00
2023-03-16 10:05:02 +08:00
app.add_middleware(
CORSMiddleware,
2023-03-20 12:07:50 +08:00
allow_origins=["*"],
2023-03-16 10:05:02 +08:00
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
2023-03-16 15:12:16 +08:00
app.mount("/static", StaticFiles(directory="static"), name="static")
2023-02-21 14:21:53 +08:00
app.include_router(api_router_v1.get_api(), prefix="/api/v1")
return app
if __name__ == "__main__":
uvicorn.run("main:get_app", host='0.0.0.0', port=5000, reload=True)