map / app.py
flyboytarantino14's picture
Update app.py
1ef3b80
import gradio as gr
import requests
import re
import html
def function(url):
response = requests.get(url)
if response.status_code == 200:
content = response.text
escaped_content = html.escape(content)
print(escaped_content)
pattern = r'APP_INITIALIZATION_STATE=\[\[\[([^]]+)\]'
matches = re.search(pattern, content, re.S)
if matches:
desired_string = matches.group(1)
# Split the string by commas
numbers_list = desired_string.split(',')
# Remove the first element (index 0) from the list
numbers_list = numbers_list[1:]
# Swap the positions of the two numbers in the list
numbers_list[0], numbers_list[1] = numbers_list[1], numbers_list[0]
# Join the remaining elements back into a string using commas as the delimiter
result_string = ','.join(numbers_list)
else:
print("String not found.")
else:
print("Failed to fetch content from the URL.")
return result_string
input = gr.Textbox()
output = gr.Textbox()
interface = gr.Interface(
fn=function,
inputs=input,
outputs=output
)
interface.launch()