Spaces:
Sleeping
Sleeping
| # app.py | |
| from fastapi import FastAPI | |
| from pydantic import BaseModel | |
| app = FastAPI() | |
| # 定義輸入/輸出資料格式 | |
| class Item(BaseModel): | |
| text: str | |
| def root(): | |
| return {"message": "Hello from FastAPI on HF Space!"} | |
| def predict(item: Item): | |
| # 模擬一個簡單推論邏輯 | |
| result = item.text.upper() | |
| return {"input": item.text, "result": result} | |
| #sample | |
| #!curl -X POST https://hsuwill000-fastapitest.hf.space/predict \ | |
| # -H "Content-Type: application/json" \ | |
| # -d '{"text":"hello world2"}' | |