33 lines
687 B
Python
33 lines
687 B
Python
"""FastAPI 主应用入口。
|
|
|
|
提供简单的 Hello World API 服务。
|
|
"""
|
|
|
|
from fastapi import FastAPI
|
|
from app.services import get_greeting, get_system_info
|
|
|
|
app = FastAPI(
|
|
title="Simple Hello API",
|
|
description="一个最简单的 FastAPI 单体示例工程",
|
|
version="1.0.0",
|
|
)
|
|
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
"""根路径,返回欢迎信息和系统信息。"""
|
|
return get_system_info()
|
|
|
|
|
|
@app.get("/hello/{name}")
|
|
async def say_hello(name: str):
|
|
"""根据传入的名字返回个性化问候。
|
|
|
|
Args:
|
|
name: 被问候者的名字。
|
|
|
|
Returns:
|
|
包含问候语的 JSON 对象。
|
|
"""
|
|
return {"message": get_greeting(name)}
|