MCPcopy Create free account
hub / github.com/OpenDCAI/Paper2Any / create_app

Function create_app

fastapi_app/main.py:58–140  ·  view source on GitHub ↗

创建 FastAPI 应用实例。 这里只做基础框架搭建: - CORS 配置 - 路由挂载 - 静态文件服务

()

Source from the content-addressed store, hash-verified

56
57
58def create_app() -> FastAPI:
59 """
60 创建 FastAPI 应用实例。
61
62 这里只做基础框架搭建:
63 - CORS 配置
64 - 路由挂载
65 - 静态文件服务
66 """
67 app = FastAPI(
68 title="DataFlow Agent FastAPI Backend",
69 version="0.1.0",
70 description="HTTP API wrapper for dataflow_agent.workflow.* pipelines",
71 )
72
73 allow_origins = _parse_cors_allow_origins(settings.CORS_ALLOW_ORIGINS)
74 allow_credentials = bool(allow_origins) and "*" not in allow_origins
75 app.add_middleware(
76 CORSMiddleware,
77 allow_origins=allow_origins,
78 allow_origin_regex=settings.CORS_ALLOW_ORIGIN_REGEX or None,
79 allow_credentials=allow_credentials,
80 allow_methods=["*"],
81 allow_headers=["*"],
82 )
83
84 # API key verification for /api/* routes
85 app.add_middleware(APIKeyMiddleware)
86
87 # 路由挂载
88 # Paper2Graph / System
89 app.include_router(paper2any.router, prefix="/api/v1", tags=["paper2any"])
90 app.include_router(paper2figure.router, prefix="/api/v1", tags=["paper2figure"])
91 app.include_router(account.router, prefix="/api/v1", tags=["account"])
92 # Paper2PPT
93 app.include_router(paper2ppt.router, prefix="/api/v1", tags=["paper2ppt"])
94 # Paper2Citation
95 app.include_router(paper2citation.router, prefix="/api/v1", tags=["paper2citation"])
96 # paper2video
97 app.include_router(paper2video.router, prefix="/api/v1", tags=["paper2video"])
98 # Paper2Poster
99 app.include_router(paper2poster.router, prefix="/api/v1", tags=["paper2poster"])
100 # PDF2PPT
101 app.include_router(pdf2ppt.router, prefix="/api/v1", tags=["pdf2ppt"])
102 # Image2PPT
103 app.include_router(image2ppt.router, prefix="/api/v1", tags=["image2ppt"])
104 # Image2DrawIO
105 app.include_router(image2drawio.router, prefix="/api/v1", tags=["image2drawio"])
106 # Image Playground
107 app.include_router(image_playground.router, prefix="/api/v1", tags=["image_playground"])
108 # MindMap
109 app.include_router(mindmap.router, prefix="/api/v1", tags=["mindmap"])
110 # 知识库接口
111 app.include_router(kb.router, prefix="/api/v1", tags=["Knowledge Base"])
112 app.include_router(kb_workflows.router, prefix="/api/v1", tags=["Knowledge Base Workflows"])
113 app.include_router(kb_embedding.router, prefix="/api/v1", tags=["Knowledge Base Embedding"])
114 # 文件管理接口
115 app.include_router(files.router, prefix="/api/v1", tags=["Files"])

Calls 2

get_project_rootFunction · 0.90