Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,37 +1,22 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
import threading
|
3 |
|
4 |
-
#
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
def greet(name):
|
9 |
-
return f"Hello, {name}!"
|
10 |
-
|
11 |
-
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
12 |
-
iface.launch(server_name="0.0.0.0", server_port=7860)
|
13 |
-
"""
|
14 |
-
|
15 |
-
# Function to execute the Gradio app dynamically
|
16 |
-
def run_gradio_app():
|
17 |
-
try:
|
18 |
-
exec(hello_world_code, {"gr": gr})
|
19 |
-
except Exception as e:
|
20 |
-
print(f"Error executing generated code: {e}")
|
21 |
|
22 |
-
|
23 |
-
def launch_app():
|
24 |
-
threading.Thread(target=run_gradio_app, daemon=True).start()
|
25 |
-
return "Hello World Gradio app launched! Refresh to see it."
|
26 |
|
27 |
-
# Gradio UI
|
28 |
with gr.Blocks() as ui:
|
29 |
-
gr.Markdown("###
|
30 |
-
launch_button = gr.Button("Launch
|
31 |
-
|
32 |
|
33 |
-
launch_button.click(
|
34 |
|
35 |
-
#
|
36 |
if __name__ == "__main__":
|
37 |
ui.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
1 |
import gradio as gr
|
2 |
+
import subprocess
|
3 |
import threading
|
4 |
|
5 |
+
# Function to launch the new Gradio app
|
6 |
+
def launch_new_gradio_app():
|
7 |
+
# Use subprocess to run the new Gradio app (new_gradio_app.py)
|
8 |
+
subprocess.Popen(["python", "new_gradio_app.py"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
+
return "New Gradio app is now running. Check the space to see the result!"
|
|
|
|
|
|
|
11 |
|
12 |
+
# Main Gradio UI with a button to start the new Gradio app
|
13 |
with gr.Blocks() as ui:
|
14 |
+
gr.Markdown("### Dynamic Gradio App Loader")
|
15 |
+
launch_button = gr.Button("Launch New Gradio App")
|
16 |
+
status = gr.Textbox(label="Status")
|
17 |
|
18 |
+
launch_button.click(launch_new_gradio_app, outputs=status)
|
19 |
|
20 |
+
# Launch the initial UI
|
21 |
if __name__ == "__main__":
|
22 |
ui.launch(server_name="0.0.0.0", server_port=7860)
|