Spaces:
Sleeping
Sleeping
| # app.py | |
| import gradio as gr | |
| import requests | |
| KOYEB_API = "https://downloadmovieab.koyeb.app" | |
| def fetch_root(): | |
| res = requests.get(KOYEB_API) | |
| return res.text | |
| def search_movie(query): | |
| url = f"{KOYEB_API}/api/search/{query}" | |
| res = requests.get(url, headers={"Accept": "application/json"}) | |
| return res.json() | |
| def trending_movies(): | |
| url = f"{KOYEB_API}/api/trending" | |
| res = requests.get(url) | |
| return res.json() | |
| def movie_info(movie_id): | |
| url = f"{KOYEB_API}/api/info/{movie_id}" | |
| res = requests.get(url) | |
| return res.json() | |
| # Gradio interface | |
| with gr.Blocks() as demo: | |
| gr.Markdown("## Movie API Proxy via Gradio") | |
| with gr.Tab("Root"): | |
| gr.Button("Fetch Root").click(fetch_root, outputs=gr.Textbox()) | |
| with gr.Tab("Search"): | |
| query_input = gr.Textbox(label="Search Query") | |
| search_btn = gr.Button("Search") | |
| search_btn.click(search_movie, inputs=query_input, outputs=gr.JSON()) | |
| with gr.Tab("Trending"): | |
| gr.Button("Trending Movies").click(trending_movies, outputs=gr.JSON()) | |
| with gr.Tab("Movie Info"): | |
| movie_id_input = gr.Textbox(label="Movie ID") | |
| info_btn = gr.Button("Get Info") | |
| info_btn.click(movie_info, inputs=movie_id_input, outputs=gr.JSON()) | |
| demo.launch() | |