aakash0563 commited on
Commit
6a387ad
1 Parent(s): 4dfc3a9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -19
app.py CHANGED
@@ -1,28 +1,22 @@
1
  import gradio as gr
 
2
 
 
 
 
 
 
 
 
3
 
4
-
5
- import gradio as gr
6
-
7
- def select_action(upload_pdf, query_question):
8
- if upload_pdf:
9
- # Implement code for handling PDF upload
10
- return import upload_pdf
11
- elif query_question:
12
- # Implement code for handling question query
13
- return import query
14
- else:
15
- return "Please select at least one action."
16
 
17
  iface = gr.Interface(
18
- fn=select_action,
19
- inputs=[
20
- gr.Checkbox("Upload PDF"),
21
- gr.Checkbox("Query the Question")
22
- ],
23
  outputs="textbox",
24
- title="Select Actions with Checkboxes",
25
- description="Choose either to upload a PDF or query a question."
26
  )
27
 
28
  iface.launch()
@@ -30,3 +24,4 @@ iface.launch()
30
 
31
 
32
 
 
 
1
  import gradio as gr
2
+ import importlib
3
 
4
+ def run_selected_app(app_file):
5
+ try:
6
+ module = importlib.import_module(app_file) # Import the specified module
7
+ interface = getattr(module, "iface") # Get the Gradio interface from the module
8
+ interface.launch(share=True) # Launch the selected app in a new tab
9
+ except Exception as e:
10
+ return f"Error loading app: {e}"
11
 
12
+ return "Selected app launched successfully!"
 
 
 
 
 
 
 
 
 
 
 
13
 
14
  iface = gr.Interface(
15
+ fn=run_selected_app,
16
+ inputs=gr.Dropdown(["upload_pdf.py", "query.py"], label="Select App"),
 
 
 
17
  outputs="textbox",
18
+ title="Run Gradio Apps",
19
+ description="Choose an app to run from the dropdown."
20
  )
21
 
22
  iface.launch()
 
24
 
25
 
26
 
27
+