File size: 1,148 Bytes
452f26d
8457e18
452f26d
8e9bd69
 
 
 
4a3ead8
8e9bd69
 
 
4a3ead8
 
8e9bd69
 
0efb599
4a3ead8
0efb599
452f26d
8e9bd69
4a3ead8
 
 
 
 
 
 
8e9bd69
4a3ead8
 
 
 
 
 
 
8457e18
8e9bd69
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
import gradio as gr
import os

def process_file(file_obj):
    if file_obj is None:
        return "No file uploaded."

    # ํŒŒ์ผ ์ €์žฅํ•˜๊ธฐ
    save_path = os.path.join(os.getcwd(), file_obj.name)
    with open(save_path, "wb") as f:
        f.write(file_obj.read())

    # ์ ˆ๋Œ€ ๊ฒฝ๋กœ ๋ฐ˜ํ™˜
    return save_path

def process_text(text):
    # ์ž…๋ ฅ๋œ ํ…์ŠคํŠธ๋ฅผ ๊ทธ๋Œ€๋กœ ๋ฐ˜ํ™˜
    return text

with gr.Blocks() as demo:
    # ํ…์ŠคํŠธ ์ž…๋ ฅ ๋ฐ ์ถœ๋ ฅ ๋ธ”๋ก
    with gr.Group():
        with gr.Row():
            text_input = gr.Textbox(label="Enter Text Here")
            submit_text_button = gr.Button("Submit Text")
        text_output = gr.Text(label="Processed Text")
        submit_text_button.click(process_text, inputs=text_input, outputs=text_output)
    
    # ํŒŒ์ผ ์ž…๋ ฅ ๋ฐ ๊ฒฝ๋กœ ์ถœ๋ ฅ ๋ธ”๋ก
    with gr.Group():
        with gr.Row():
            file_input = gr.File(label="Drag & Drop File Here")
            submit_file_button = gr.Button("Submit File")
        file_output = gr.Text(label="File Path")
        submit_file_button.click(process_file, inputs=file_input, outputs=file_output)

demo.launch()