feat: add fs-backend service

This commit is contained in:
tao.chen
2026-07-29 10:07:13 +08:00
parent 59a1b5e4d4
commit a4e4e5b0db
12 changed files with 915 additions and 0 deletions
+40
View File
@@ -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"}