| from fastapi import FastAPI | |
| from fastapi.responses import JSONResponse | |
| # 创建 FastAPI 应用实例 | |
| app = FastAPI( | |
| title="HFBase API", | |
| description="基于 Node.js + Python 的最简 API 服务", | |
| version="1.0.0" | |
| ) | |
| async def root(): | |
| """根端点,返回基本信息""" | |
| return JSONResponse( | |
| content={ | |
| "message": "欢迎使用 HFBase API", | |
| "version": "1.0.0", | |
| "status": "运行中" | |
| } | |
| ) | |
| async def health_check(): | |
| """健康检查端点""" | |
| return JSONResponse( | |
| content={"status": "ok"}, | |
| status_code=200 | |
| ) | |
| async def info(): | |
| """系统信息端点""" | |
| return JSONResponse( | |
| content={ | |
| "framework": "FastAPI", | |
| "python_version": "3.12", | |
| "nodejs_version": "20 LTS", | |
| "deployment": "HuggingFace Spaces" | |
| } | |
| ) | |