Update app.py
Browse files
app.py
CHANGED
@@ -5,28 +5,33 @@ def process_file(file_obj):
|
|
5 |
if file_obj is None:
|
6 |
return "No file uploaded."
|
7 |
|
|
|
8 |
save_path = os.path.join(os.getcwd(), file_obj.name)
|
9 |
with open(save_path, "wb") as f:
|
10 |
f.write(file_obj.read())
|
|
|
|
|
11 |
return save_path
|
12 |
|
13 |
def process_text(text):
|
|
|
14 |
return text
|
15 |
|
16 |
with gr.Blocks() as demo:
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
text_input = gr.Textbox(label="Enter Text Here")
|
25 |
-
submit_text_button = gr.Button("Submit Text")
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
31 |
|
32 |
demo.launch()
|
|
|
5 |
if file_obj is None:
|
6 |
return "No file uploaded."
|
7 |
|
8 |
+
# ํ์ผ ์ ์ฅํ๊ธฐ
|
9 |
save_path = os.path.join(os.getcwd(), file_obj.name)
|
10 |
with open(save_path, "wb") as f:
|
11 |
f.write(file_obj.read())
|
12 |
+
|
13 |
+
# ์ ๋ ๊ฒฝ๋ก ๋ฐํ
|
14 |
return save_path
|
15 |
|
16 |
def process_text(text):
|
17 |
+
# ์
๋ ฅ๋ ํ
์คํธ๋ฅผ ๊ทธ๋๋ก ๋ฐํ
|
18 |
return text
|
19 |
|
20 |
with gr.Blocks() as demo:
|
21 |
+
# ํ
์คํธ ์
๋ ฅ ๋ฐ ์ถ๋ ฅ ๋ธ๋ก
|
22 |
+
with gr.Group():
|
23 |
+
with gr.Row():
|
24 |
+
text_input = gr.Textbox(label="Enter Text Here")
|
25 |
+
submit_text_button = gr.Button("Submit Text")
|
26 |
+
text_output = gr.Text(label="Processed Text")
|
27 |
+
submit_text_button.click(process_text, inputs=text_input, outputs=text_output)
|
|
|
|
|
28 |
|
29 |
+
# ํ์ผ ์
๋ ฅ ๋ฐ ๊ฒฝ๋ก ์ถ๋ ฅ ๋ธ๋ก
|
30 |
+
with gr.Group():
|
31 |
+
with gr.Row():
|
32 |
+
file_input = gr.File(label="Drag & Drop File Here")
|
33 |
+
submit_file_button = gr.Button("Submit File")
|
34 |
+
file_output = gr.Text(label="File Path")
|
35 |
+
submit_file_button.click(process_file, inputs=file_input, outputs=file_output)
|
36 |
|
37 |
demo.launch()
|