Spaces:
Paused
Paused
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
from pydantic import BaseModel
|
| 3 |
+
import uvicorn
|
| 4 |
+
|
| 5 |
+
app = FastAPI()
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
class Item(BaseModel):
|
| 9 |
+
claim: str
|
| 10 |
+
source: str
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
@app.get("/")
|
| 14 |
+
def greet_json():
|
| 15 |
+
return {"Hello": "World!"}
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def generate(item: Item):
|
| 19 |
+
return "Claim: " + item.claim
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
@app.post("/generate/")
|
| 23 |
+
async def generate_text(item: Item):
|
| 24 |
+
return {"response": generate(item)}
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
if __name__ == "__main__":
|
| 28 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|
| 29 |
+
|