31 lines
610 B
Python
31 lines
610 B
Python
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)
|