dataset_PII_checker / server.py
Ezi Ozoani
fix app init
711adee
raw
history blame contribute delete
874 Bytes
import os
from fastapi import FastAPI, Request, Response
from main import create_or_update_report
from tabulate import tabulate
KEY = os.environ.get("KEY")
main = FastAPI()
@main.get("/")
def read_root():
data = """
<h2 style="text-align:center">Metadata Review Bot</h2>
<p style="text-align:center">This is a demo app showing how to use webhooks to automate metadata review for models and datasets shared on the Hugging Face Hub.</p>
"""
return Response(content=data, media_type="text/html")
@main.post("/webhook")
async def webhook(request: Request):
if request.method == "POST":
if request.headers.get("X-Webhook-Secret") != KEY:
return Response("Invalid secret", status_code=401)
data = await request.json()
result = create_or_update_report(data)
return "Webhook received!" if result else result