-
Notifications
You must be signed in to change notification settings - Fork 872
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2774 from InfinityPacer/feature/api
feat(api): add support for dynamic plugin APIs
- Loading branch information
Showing
7 changed files
with
295 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from fastapi import FastAPI | ||
from fastapi.middleware.cors import CORSMiddleware | ||
|
||
from app.core.config import settings | ||
from app.startup.lifecycle import lifespan | ||
|
||
|
||
def create_app() -> FastAPI: | ||
""" | ||
创建并配置 FastAPI 应用实例。 | ||
""" | ||
app = FastAPI( | ||
title=settings.PROJECT_NAME, | ||
openapi_url=f"{settings.API_V1_STR}/openapi.json", | ||
lifespan=lifespan | ||
) | ||
|
||
# 配置 CORS 中间件 | ||
app.add_middleware( | ||
CORSMiddleware, | ||
allow_origins=settings.ALLOWED_HOSTS, | ||
allow_credentials=True, | ||
allow_methods=["*"], | ||
allow_headers=["*"], | ||
) | ||
|
||
return app | ||
|
||
|
||
# 创建 FastAPI 应用实例 | ||
app = create_app() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.