reach-vb's picture
reach-vb HF staff
Update app.py
39c1111
raw
history blame
631 Bytes
"""
"""
import re
from fastapi import FastAPI
from fastapi import Request
app = FastAPI()
items = []
url_re = re.compile(r'https://s3\.amazonaws\.com/moonup/production/uploads/\d+-noauth\.jpeg')
@app.get("/")
async def get_events():
return items
@app.post("/webhook")
async def webhook(request: Request):
global items
payload = await request.json()
event = payload["event"]
if event["action"] != "create":
return
if event["scope"] != "discussion":
return
content = payload["comment"]["content"]
title = payload["discussion"]["title"]
image_urls = url_re.findall(content)