Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,12 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
|
4 |
def get_file_content(file):
|
@@ -6,20 +14,6 @@ def get_file_content(file):
|
|
6 |
|
7 |
|
8 |
with gr.Blocks() as demo:
|
9 |
-
gr.Markdown("---")
|
10 |
-
gr.Markdown('### `FileExplorer` to `Code` -- `file_count="single"`')
|
11 |
-
with gr.Group():
|
12 |
-
with gr.Row():
|
13 |
-
file_3 = gr.FileExplorer(
|
14 |
-
scale=1,
|
15 |
-
file_count="single",
|
16 |
-
elem_id="file",
|
17 |
-
)
|
18 |
-
|
19 |
-
code = gr.Code(lines=30, scale=2, language="python")
|
20 |
-
|
21 |
-
file_3.change(get_file_content, file_3, code)
|
22 |
-
|
23 |
gr.Markdown("---")
|
24 |
gr.Markdown('### `FileExplorer` to `Image` "`')
|
25 |
with gr.Group():
|
@@ -32,7 +26,8 @@ with gr.Blocks() as demo:
|
|
32 |
|
33 |
img = gr.Image(scale=2)
|
34 |
|
35 |
-
file_4.change(get_file_content
|
|
|
36 |
|
37 |
if __name__ == "__main__":
|
38 |
demo.launch(debug=True)
|
|
|
1 |
import gradio as gr
|
2 |
+
import logging
|
3 |
+
import json
|
4 |
+
|
5 |
+
# Set up logging
|
6 |
+
logging.basicConfig(
|
7 |
+
level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s"
|
8 |
+
)
|
9 |
+
logger = logging.getLogger(__name__)
|
10 |
|
11 |
|
12 |
def get_file_content(file):
|
|
|
14 |
|
15 |
|
16 |
with gr.Blocks() as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
gr.Markdown("---")
|
18 |
gr.Markdown('### `FileExplorer` to `Image` "`')
|
19 |
with gr.Group():
|
|
|
26 |
|
27 |
img = gr.Image(scale=2)
|
28 |
|
29 |
+
file_4.change(logger.info(json.dumps(get_file_content)))
|
30 |
+
# file_4.change(get_file_content, file_4, img)
|
31 |
|
32 |
if __name__ == "__main__":
|
33 |
demo.launch(debug=True)
|