Spaces:
Runtime error
Runtime error
| import os | |
| import sys | |
| # Get the absolute path of the directory containing app.py | |
| current_dir = os.path.dirname(os.path.abspath(__file__)) | |
| # Add it to the system path | |
| if current_dir not in sys.path: | |
| sys.path.insert(0, current_dir) | |
| import gradio as gr | |
| # Now the imports should work | |
| from scripts.codeforces_sync import run_cf_sync | |
| from scripts.leetcode_fetch import run_lc_sync | |
| # ... rest of your Gradio code ... | |
| def handle_cf(): | |
| # Calling the function from our script | |
| return run_cf_sync() | |
| def handle_lc(mode): | |
| # Calling the function from our script | |
| return run_lc_sync(mode) | |
| with gr.Blocks() as demo: | |
| gr.Markdown("# Problem Scraper API") | |
| with gr.Row(): | |
| cf_btn = gr.Button("Sync Codeforces") | |
| cf_file = gr.File(label="CF Output") | |
| with gr.Row(): | |
| mode_select = gr.Dropdown(["daily", "sync", "details"], value="daily") | |
| lc_btn = gr.Button("Sync LeetCode") | |
| lc_file = gr.File(label="LC Output") | |
| cf_btn.click(handle_cf, outputs=cf_file, api_name="cf_sync") | |
| lc_btn.click(handle_lc, inputs=mode_select, outputs=lc_file, api_name="lc_sync") | |
| demo.launch() |