File size: 1,441 Bytes
9bb703d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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)