Spaces:
Runtime error
Runtime error
Include title
Browse files
app.py
CHANGED
@@ -9,17 +9,17 @@ from fastapi import Request
|
|
9 |
|
10 |
app = FastAPI()
|
11 |
|
12 |
-
|
13 |
|
14 |
url_re = re.compile(r'https://s3\.amazonaws\.com/moonup/production/uploads/\d+-noauth\.jpeg')
|
15 |
|
16 |
@app.get("/")
|
17 |
async def get_events():
|
18 |
-
return
|
19 |
|
20 |
@app.post("/webhook")
|
21 |
async def webhook(request: Request):
|
22 |
-
global
|
23 |
payload = await request.json()
|
24 |
event = payload["event"]
|
25 |
if event["action"] != "create":
|
@@ -27,4 +27,6 @@ async def webhook(request: Request):
|
|
27 |
if event["scope"] != "discussion":
|
28 |
return
|
29 |
content = payload["comment"]["content"]
|
30 |
-
|
|
|
|
|
|
9 |
|
10 |
app = FastAPI()
|
11 |
|
12 |
+
items = []
|
13 |
|
14 |
url_re = re.compile(r'https://s3\.amazonaws\.com/moonup/production/uploads/\d+-noauth\.jpeg')
|
15 |
|
16 |
@app.get("/")
|
17 |
async def get_events():
|
18 |
+
return items
|
19 |
|
20 |
@app.post("/webhook")
|
21 |
async def webhook(request: Request):
|
22 |
+
global items
|
23 |
payload = await request.json()
|
24 |
event = payload["event"]
|
25 |
if event["action"] != "create":
|
|
|
27 |
if event["scope"] != "discussion":
|
28 |
return
|
29 |
content = payload["comment"]["content"]
|
30 |
+
title = payload["discussion"]["title"]
|
31 |
+
for url in url_re.findall(content):
|
32 |
+
items += [(title, url)]
|