Spaces:
Sleeping
Sleeping
import requests | |
import gradio as gr | |
def fetch_feed(feed_url): | |
response = requests.get( | |
feed_url, | |
headers={ | |
"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" | |
}, | |
timeout=10, | |
) | |
if response.status_code == 200: | |
return { | |
"status": "ok", | |
"data": response.text | |
} | |
else: | |
return { | |
"status": "not-ok", | |
"data": { | |
"status_code": response.status_code, | |
"error": response.text | |
} | |
} | |
theme = gr.themes.Soft( | |
primary_hue="purple", | |
secondary_hue="cyan", | |
neutral_hue="slate", | |
font=[ | |
gr.themes.GoogleFont("Syne"), | |
gr.themes.GoogleFont("Poppins"), | |
gr.themes.GoogleFont("Poppins"), | |
gr.themes.GoogleFont("Poppins") | |
], | |
) | |
with gr.Blocks(theme=theme, title="CORS Proxy") as app: | |
with gr.Row(): | |
with gr.Column(): | |
url = gr.Textbox(label="Enter URL", placeholder="https://example.com/rss.xml") | |
submit = gr.Button(value="Fetch Feed") | |
with gr.Column(): | |
feed = gr.Textbox(label="Feed", show_copy_button=True, placeholder="Feed will appear here") | |
submit.click(fetch_feed, inputs=[url], outputs=[feed]) | |
app.queue(default_concurrency_limit=500).launch(show_api=True, ssr_mode=False) |