-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
31 lines (24 loc) · 1.04 KB
/
Copy pathapp.py
File metadata and controls
31 lines (24 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import streamlit as st
import os
st.title("Deep ML Practice Problems Explorer")
# Set the root directory for problems (adjust if needed)
PROBLEM_ROOT = os.path.dirname(os.path.abspath(__file__))
def find_problem_files(root):
py_files = []
for dirpath, dirnames, filenames in os.walk(root):
for fname in filenames:
if fname.endswith(".py") and fname != "app.py":
rel_path = os.path.relpath(os.path.join(dirpath, fname), root)
py_files.append(rel_path)
return sorted(py_files)
problem_files = find_problem_files(PROBLEM_ROOT)
st.sidebar.header("Select a Problem File")
selected_file = st.sidebar.selectbox("Python files:", problem_files)
if selected_file:
st.subheader(f"Viewing: `{selected_file}`")
file_path = os.path.join(PROBLEM_ROOT, selected_file)
with open(file_path, "r", encoding="utf-8") as f:
code = f.read()
st.code(code, language="python")
st.sidebar.markdown("---")
st.sidebar.info("Add new `.py` files to your repo and they will appear here automatically.")