25 lines
484 B
Python
25 lines
484 B
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from app.api.v1.api import router
|
|
|
|
|
|
app = FastAPI(
|
|
title="测试fastapi",
|
|
description="测试啊",
|
|
version="1.0.0"
|
|
)
|
|
|
|
# 配置CORS
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
app.include_router(router, prefix="/api/v1")
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
return {"message": "测试成功"} |