Spaces:
Running
Running
File size: 744 Bytes
6e19f63 add86c7 5b43964 add86c7 cb42996 add86c7 5b43964 add86c7 b867a1d add86c7 cb42996 add86c7 989b57a 5b43964 70a718e add86c7 e1c280b add86c7 b54eb41 989b57a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import gradio as gr
import os
import signal
import subprocess
import sys
# Function to stop the current Gradio app and launch a new one
def launch_new_gradio_app():
# Start the new Gradio app in the same process space
subprocess.Popen(["python", "new_gradio_app.py"], stdout=sys.stdout, stderr=sys.stderr)
# Gracefully exit the current Gradio app
os.kill(os.getpid(), signal.SIGTERM)
# Gradio UI with a button to switch apps
with gr.Blocks() as ui:
gr.Markdown("### Dynamic Gradio App Loader")
launch_button = gr.Button("Launch New Gradio App")
launch_button.click(launch_new_gradio_app, outputs=[])
# Start the initial Gradio UI
if __name__ == "__main__":
ui.launch(server_name="0.0.0.0", server_port=7860) |