summaryapi / main.py
quyip
fix
0433163
raw
history blame
414 Bytes
from fastapi import FastAPI
from pydantic import BaseModel
from summary import summarize
KEY = 'J9l#K4wP5h@2'
app = FastAPI()
@app.get("/")
async def root():
return {"message": "Hello World"}
class SummaryReq(BaseModel):
text: str
key: str
@app.post("/summary/")
async def summary(request: SummaryReq):
if request.key != KEY:
return 'Unauthorized'
return summarize(request.text)