Spaces:
Configuration error
Configuration error
Update app.py
#3
by LeahRocks - opened
app.py
CHANGED
|
@@ -1,40 +1,26 @@
|
|
| 1 |
-
from fastapi import FastAPI
|
| 2 |
-
from fastapi.
|
| 3 |
-
from fastapi.
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
app =
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
"decision": "flag",
|
| 28 |
-
"confidence": 0.85,
|
| 29 |
-
"explanation": "Potentially harmful content detected",
|
| 30 |
-
"ai_scores": {
|
| 31 |
-
"toxicity": 0.8,
|
| 32 |
-
"insult": 0.6,
|
| 33 |
-
"threat": 0.7,
|
| 34 |
-
"obscene": 0.5
|
| 35 |
-
}
|
| 36 |
-
}
|
| 37 |
-
|
| 38 |
-
# Run locally
|
| 39 |
-
if __name__ == "__main__":
|
| 40 |
-
uvicorn.run(app, host="0.0.0.0", port=7860)
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
from fastapi.staticfiles import StaticFiles
|
| 3 |
+
from fastapi.responses import FileResponse
|
| 4 |
+
import os
|
| 5 |
+
|
| 6 |
+
app = FastAPI()
|
| 7 |
+
|
| 8 |
+
app.mount("/static", StaticFiles(directory="static"), name="static")
|
| 9 |
+
|
| 10 |
+
@app.get("/")
|
| 11 |
+
async def home():
|
| 12 |
+
return FileResponse(os.path.join("templates", "index.html"))
|
| 13 |
+
|
| 14 |
+
@app.post("/moderate")
|
| 15 |
+
async def moderate(data: dict):
|
| 16 |
+
return {
|
| 17 |
+
"decision": "flag",
|
| 18 |
+
"confidence": 0.85,
|
| 19 |
+
"explanation": "Potentially harmful content detected",
|
| 20 |
+
"ai_scores": {
|
| 21 |
+
"toxicity": 0.8,
|
| 22 |
+
"insult": 0.6,
|
| 23 |
+
"threat": 0.7,
|
| 24 |
+
"obscene": 0.5
|
| 25 |
+
}
|
| 26 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|