File size: 582 Bytes
84e7849 |
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 |
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": "获取当前文本"
}
} |