Spaces:
Runtime error
Runtime error
File size: 775 Bytes
7a3d7a6 |
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 |
import os
from fastapi import FastAPI, Request, Response
from main import parse_webhook_post, run_compliance_check, create_or_update_report
KEY = os.environ.get("KEY")
app = FastAPI()
@app.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()
if parsed_post := parse_webhook_post(data):
repo_name = parsed_post
else:
return Response("Unable to parse webhook data", status_code=400)
compliance_check = run_compliance_check(repo_name)
result = create_or_update_report(compliance_check, repo_name)
return result
|