Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
def fetch_feed(feed_url):
|
5 |
+
response = requests.get(
|
6 |
+
feed_url,
|
7 |
+
headers={
|
8 |
+
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; Storebot-Google/1.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.6723.170 Safari/537.36"
|
9 |
+
},
|
10 |
+
timeout=10,
|
11 |
+
)
|
12 |
+
if response.status_code == 200:
|
13 |
+
return {
|
14 |
+
"status": "ok",
|
15 |
+
"data": response.text
|
16 |
+
}
|
17 |
+
else:
|
18 |
+
return {
|
19 |
+
"status": "not-ok",
|
20 |
+
"data": {
|
21 |
+
"status_code": response.status_code,
|
22 |
+
"error": response.text
|
23 |
+
}
|
24 |
+
}
|
25 |
+
|
26 |
+
theme = gr.themes.Soft(
|
27 |
+
primary_hue="purple",
|
28 |
+
secondary_hue="cyan",
|
29 |
+
neutral_hue="slate",
|
30 |
+
font=[
|
31 |
+
gr.themes.GoogleFont("Syne"),
|
32 |
+
gr.themes.GoogleFont("Poppins"),
|
33 |
+
gr.themes.GoogleFont("Poppins"),
|
34 |
+
gr.themes.GoogleFont("Poppins")
|
35 |
+
],
|
36 |
+
)
|
37 |
+
|
38 |
+
with gr.Blocks(theme=theme, title="CORS Proxy") as app:
|
39 |
+
with gr.Row():
|
40 |
+
with gr.Column():
|
41 |
+
url = gr.Textbox(label="Enter URL", placeholder="https://example.com/rss.xml")
|
42 |
+
submit = gr.Button(value="Fetch Feed")
|
43 |
+
with gr.Column():
|
44 |
+
feed = gr.Textbox(label="Feed", show_copy_button=True, placeholder="Feed will appear here")
|
45 |
+
submit.click(fetch_feed, inputs=[url], outputs=[feed])
|
46 |
+
|
47 |
+
app.queue(default_concurrency_limit=500).launch(show_api=True, ssr_mode=False)
|