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()