Spaces:
Running
Running
test
Browse files
main.py
CHANGED
|
@@ -3,6 +3,7 @@
|
|
| 3 |
|
| 4 |
from fastapi import FastAPI,Request
|
| 5 |
import uvicorn
|
|
|
|
| 6 |
|
| 7 |
app = FastAPI()
|
| 8 |
|
|
@@ -13,10 +14,17 @@ app = FastAPI()
|
|
| 13 |
def root():
|
| 14 |
return {"API": "Sum of 2 Squares"}
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
@app.post("/predict")
|
| 17 |
-
async def predict(request:
|
| 18 |
-
|
|
|
|
| 19 |
prompt = data.get("prompt")
|
| 20 |
return f"您好,{prompt}"
|
| 21 |
|
| 22 |
-
|
|
|
|
| 3 |
|
| 4 |
from fastapi import FastAPI,Request
|
| 5 |
import uvicorn
|
| 6 |
+
import json
|
| 7 |
|
| 8 |
app = FastAPI()
|
| 9 |
|
|
|
|
| 14 |
def root():
|
| 15 |
return {"API": "Sum of 2 Squares"}
|
| 16 |
|
| 17 |
+
@app.post("/img2img")
|
| 18 |
+
async def predict(url:str,prompt:str):
|
| 19 |
+
body = await request.body()
|
| 20 |
+
data = json.loads(body)
|
| 21 |
+
prompt = data.get("prompt")
|
| 22 |
+
return f"您好,{url+prompt}"
|
| 23 |
+
|
| 24 |
@app.post("/predict")
|
| 25 |
+
async def predict(request:Request):
|
| 26 |
+
body = await request.body()
|
| 27 |
+
data = json.loads(body)
|
| 28 |
prompt = data.get("prompt")
|
| 29 |
return f"您好,{prompt}"
|
| 30 |
|
|
|