cbensimon HF staff commited on
Commit
0cb9be7
·
1 Parent(s): 654fde1

Include title

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -9,17 +9,17 @@ from fastapi import Request
9
 
10
  app = FastAPI()
11
 
12
- urls = []
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 urls
19
 
20
  @app.post("/webhook")
21
  async def webhook(request: Request):
22
- global urls
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
- urls += url_re.findall(content)
 
 
 
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)]