File size: 2,597 Bytes
c666af5
 
 
96ba60d
 
819ad21
 
b044e50
8d6eb18
b044e50
96ba60d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b044e50
96ba60d
a1fd886
 
96ba60d
a1fd886
96ba60d
 
8d6eb18
96ba60d
 
b044e50
96ba60d
7c56974
 
 
 
 
38b8062
0bcf7ca
 
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import gradio as gr


# --- Init params ---
def init_params(text, request: gr.Request):
    youtube_link = ""
    password_text = ""
    block_ready_flag = "READY"
    admin = gr.update(visible=True)
    return admin, password_text, youtube_link, block_ready_flag

HEAD = """
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
    svg.markmap {{
        width: 100%;
        height: 100vh;
    }}
    </style>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
    <script>
        const mind_map_tab_button = document.querySelector("#mind_map_tab-button");
        
        if (mind_map_tab_button) {
            mind_map_tab_button.addEventListener('click', function() {
                const mind_map_markdown = document.querySelector("#mind_map_markdown > label > textarea");
                if (mind_map_markdown) {
                // 当按钮被点击时,打印当前的textarea的值
                console.log('Value changed to: ' + mind_map_markdown.value);
                markmap.autoLoader.renderAll();
                }
            });
        }
    </script>
"""

with gr.Blocks(theme=gr.themes.Base(primary_hue=gr.themes.colors.orange, secondary_hue=gr.themes.colors.amber, text_size = gr.themes.sizes.text_lg), head=HEAD) as demo:
    with gr.Row() as admin:
        password = gr.Textbox(label="Password", type="password", elem_id="password_input", visible=True)
        youtube_link = gr.Textbox(label="Enter YouTube Link", elem_id="youtube_link_input", visible=True)
        video_id = gr.Textbox(label="video_id", visible=True)
        # file_upload = gr.File(label="Upload your CSV or Word file", visible=False)
        # web_link = gr.Textbox(label="Enter Web Page Link", visible=False)
        user_data = gr.Textbox(label="User Data", elem_id="user_data_input", visible=True)
        block_ready_flag = gr.Textbox(label="load_ready_flag", elem_id="block_ready_flag", value="LOADING", visible=True)
        youtube_link_btn = gr.Button("Submit_YouTube_Link", elem_id="youtube_link_btn", visible=True)
    with gr.Row() as data_state:
        content_subject_state = gr.State()  # 使用 gr.State 存储 content_subject

    
    # init_params
    init_outputs = [
        admin,
        password, 
        youtube_link,
        block_ready_flag,
    ]
    demo.load(
        init_params, 
        inputs =[youtube_link],
        outputs = init_outputs
    )
    block_ready_flag.visible = False

demo.launch(allowed_paths=["videos"], server_name="0.0.0.0", server_port=7860)