flyboytarantino14 commited on
Commit
a33964b
·
1 Parent(s): 4caae5b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+ import re
4
+ import html
5
+
6
+ def function(url):
7
+ response = requests.get(url)
8
+ if response.status_code == 200:
9
+ content = response.text
10
+ escaped_content = html.escape(content)
11
+ print(escaped_content)
12
+ pattern = r'APP_INITIALIZATION_STATE=\[\[\[([^]]+)\]'
13
+ matches = re.search(pattern, content, re.S)
14
+ if matches:
15
+ desired_string = matches.group(1)
16
+ print(desired_string)
17
+ else:
18
+ print("String not found.")
19
+ else:
20
+ print("Failed to fetch content from the URL.")
21
+ return desired_string
22
+
23
+ input = gr.Textbox()
24
+ output = gr.Textbox()
25
+
26
+ interface = gr.Interface(
27
+ fn=function,
28
+ inputs=input,
29
+ outputs=output
30
+ )
31
+
32
+ interface.launch()