feat: add fs-backend service
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
"""
|
||||
FastAPI 后端服务主入口
|
||||
"""
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
from app.core.config import settings
|
||||
from app.routers import fs
|
||||
|
||||
|
||||
def create_app() -> FastAPI:
|
||||
"""创建并配置 FastAPI 应用实例"""
|
||||
app = FastAPI(
|
||||
title="OpenCode Backend API",
|
||||
description="OpenCode 后端服务接口",
|
||||
version="1.0.0",
|
||||
)
|
||||
|
||||
# 配置 CORS
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=settings.CORS_ORIGINS,
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
# 注册路由
|
||||
app.include_router(fs.router, prefix="/fs", tags=["文件系统"])
|
||||
|
||||
return app
|
||||
|
||||
|
||||
app = create_app()
|
||||
|
||||
|
||||
@app.get("/")
|
||||
async def root():
|
||||
"""健康检查接口"""
|
||||
return {"status": "ok", "message": "OpenCode Backend API is running"}
|
||||
Reference in New Issue
Block a user