File size: 646 Bytes
432ccbd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
from fastapi.responses import FileResponse
import os

app = FastAPI()

app.mount("/static", StaticFiles(directory="static"), name="static")

@app.get("/")
async def home():
    return FileResponse(os.path.join("templates", "index.html"))

@app.post("/moderate")
async def moderate(data: dict):
    return {
        "decision": "flag",
        "confidence": 0.85,
        "explanation": "Potentially harmful content detected",
        "ai_scores": {
            "toxicity": 0.8,
            "insult": 0.6,
            "threat": 0.7,
            "obscene": 0.5
        }
    }