File size: 927 Bytes
ec2e14a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
from fastapi import FastAPI
from fastapi.responses import JSONResponse
# 创建 FastAPI 应用实例
app = FastAPI(
title="HFBase API",
description="基于 Node.js + Python 的最简 API 服务",
version="1.0.0"
)
@app.get("/")
async def root():
"""根端点,返回基本信息"""
return JSONResponse(
content={
"message": "欢迎使用 HFBase API",
"version": "1.0.0",
"status": "运行中"
}
)
@app.get("/health")
async def health_check():
"""健康检查端点"""
return JSONResponse(
content={"status": "ok"},
status_code=200
)
@app.get("/info")
async def info():
"""系统信息端点"""
return JSONResponse(
content={
"framework": "FastAPI",
"python_version": "3.12",
"nodejs_version": "20 LTS",
"deployment": "HuggingFace Spaces"
}
)
|