Spaces:
Running
Running
File size: 620 Bytes
0ed2ee7 22c4eb1 ee259c3 e07c4e9 3671cba 697988f d687e0e 0ed2ee7 d687e0e e07c4e9 faf9078 e07c4e9 22c4eb1 e07c4e9 0950a65 ee259c3 |
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 |
# https://medium.com/@qacheampong/building-and-deploying-a-fastapi-app-with-hugging-face-9210e9b4a713
# https://huggingface.co/spaces/Queensly/FastAPI_in_Docker
from fastapi import FastAPI,Request
import uvicorn
import json
app = FastAPI()
#Endpoints
#Root endpoints
@app.get("/")
def root():
return {"API": "Sum of 2 Squares"}
@app.post("/img2img")
async def predict(url:str,prompt:str):
return f"您好,{url+prompt}"
@app.post("/predict")
async def predict(request:Request):
body = await request.body()
data = json.loads(body)
prompt = data.get("prompt")
return f"您好,{prompt}"
|