first commit
This commit is contained in:
30
server/app.py
Normal file
30
server/app.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from fastapi import FastAPI
|
||||
from server.servers import servers_lifespan
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
async def lifespan(app: FastAPI):
|
||||
async with servers_lifespan(app):
|
||||
yield
|
||||
|
||||
app = FastAPI(
|
||||
title="Leaves API",
|
||||
version="1.0",
|
||||
description="Leaves API",
|
||||
lifespan=lifespan,
|
||||
contact={
|
||||
"name": "Seayu",
|
||||
"email": "yhyuhai13@163.com",
|
||||
},
|
||||
)
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"],
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
import uvicorn
|
||||
uvicorn.run(app, host="0.0.0.0", port=12345)
|
||||
Reference in New Issue
Block a user