Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -54,22 +54,22 @@ with gr.Blocks() as app:
|
|
54 |
gen_project_btn.click(fn=generate_project, outputs=scaffold_output)
|
55 |
|
56 |
with gr.Tab("π File Tools"):
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
|
74 |
with gr.Tab("π Markdown Preview"):
|
75 |
md_input = gr.Textbox(label="Paste Markdown (README.md)", lines=12)
|
|
|
54 |
gen_project_btn.click(fn=generate_project, outputs=scaffold_output)
|
55 |
|
56 |
with gr.Tab("π File Tools"):
|
57 |
+
file_upload = gr.File(label="Upload Code File", type="filepath")
|
58 |
+
file_view = gr.Code(label="Uploaded File Content", language="python")
|
59 |
+
export_btn = gr.Button("Export as .py File")
|
60 |
+
file_download = gr.File(label="Download File")
|
61 |
+
|
62 |
+
def load_file(f):
|
63 |
+
return open(f.name, 'r').read()
|
64 |
+
|
65 |
+
def export_code(code):
|
66 |
+
filename = "dev_output.py"
|
67 |
+
with open(filename, "w") as f:
|
68 |
+
f.write(code)
|
69 |
+
return filename
|
70 |
+
|
71 |
+
file_upload.change(fn=load_file, inputs=file_upload, outputs=file_view)
|
72 |
+
export_btn.click(fn=export_code, inputs=file_view, outputs=file_download)
|
73 |
|
74 |
with gr.Tab("π Markdown Preview"):
|
75 |
md_input = gr.Textbox(label="Paste Markdown (README.md)", lines=12)
|