File size: 1,136 Bytes
390a186
b0bc5e7
390a186
b0bc5e7
 
 
 
 
390a186
5236d13
b0bc5e7
5236d13
 
 
b0bc5e7
 
5236d13
390a186
5236d13
 
 
390a186
5236d13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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()