cbensimon HF staff commited on
Commit
a18602d
·
1 Parent(s): 0d68e6c

Parse URLs in content

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -1,19 +1,25 @@
1
  """
2
  """
3
 
 
 
4
  from fastapi import FastAPI
5
  from fastapi import Request
6
 
7
 
8
- events = []
9
-
10
  app = FastAPI()
11
 
 
 
 
 
12
  @app.get("/")
13
  async def get_events():
14
- return events
15
 
16
  @app.post("/webhook")
17
  async def webhook(request: Request):
18
- global events
19
- events += [await request.json()]
 
 
 
1
  """
2
  """
3
 
4
+ import re
5
+
6
  from fastapi import FastAPI
7
  from fastapi import Request
8
 
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
+ event = await request.json()
24
+ content = event["content"]
25
+ urls += url_re.findall(content)