Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import importlib.util
|
3 |
+
import sys
|
4 |
+
import os
|
5 |
+
|
6 |
+
# Define the options in the dropdown menu
|
7 |
+
app_options = {
|
8 |
+
"Create CSVs": "create",
|
9 |
+
"Merge CSVs": "merge",
|
10 |
+
"Upload Datasets": "upload",
|
11 |
+
"Create Chatbot": "chatbot"
|
12 |
+
}
|
13 |
+
|
14 |
+
# Sidebar dropdown for selecting the application
|
15 |
+
selected_app = st.sidebar.selectbox("Select Application", list(app_options.keys()))
|
16 |
+
|
17 |
+
# Clear session state when switching apps
|
18 |
+
if 'last_selected_app' in st.session_state:
|
19 |
+
if st.session_state.last_selected_app != selected_app:
|
20 |
+
st.session_state.clear()
|
21 |
+
|
22 |
+
st.session_state.last_selected_app = selected_app
|
23 |
+
|
24 |
+
# Function to load and run the selected application
|
25 |
+
def load_app(app_path):
|
26 |
+
module_name = os.path.splitext(os.path.basename(app_path))[0]
|
27 |
+
|
28 |
+
if module_name in sys.modules:
|
29 |
+
del sys.modules[module_name]
|
30 |
+
|
31 |
+
spec = importlib.util.spec_from_file_location(module_name, app_path)
|
32 |
+
module = importlib.util.module_from_spec(spec)
|
33 |
+
sys.modules[module_name] = module
|
34 |
+
spec.loader.exec_module(module)
|
35 |
+
|
36 |
+
# Load and run the selected application
|
37 |
+
load_app(app_options[selected_app])
|