from fastapi import FastAPI from pydantic import BaseModel from datetime import datetime app = FastAPI() STORE = { "text": "", "updated_at": None } class TextIn(BaseModel): text: str @app.post("/set") def set_text(data: TextIn): STORE["text"] = data.text STORE["updated_at"] = datetime.utcnow().isoformat() return {"ok": True} @app.get("/get") def get_text(): return STORE @app.get("/") def info(): return { "usage": { "POST /set": {"text": "要粘贴的内容"}, "GET /get": "获取当前文本" } }