Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import os
|
3 |
+
|
4 |
+
# Function to read markdown files
|
5 |
+
def load_markdown_file(path):
|
6 |
+
with open(path, 'r') as file:
|
7 |
+
content = file.read()
|
8 |
+
return content
|
9 |
+
|
10 |
+
# Streamlit UI
|
11 |
+
st.title('Documentation')
|
12 |
+
|
13 |
+
# Assuming your documentation is in the 'docs' folder
|
14 |
+
docs_base_path = './doc'
|
15 |
+
|
16 |
+
# List categories based on folder names
|
17 |
+
categories = [d for d in os.listdir(docs_base_path) if os.path.isdir(os.path.join(docs_base_path, d))]
|
18 |
+
category = st.sidebar.selectbox('Select a Category', categories)
|
19 |
+
|
20 |
+
# List pages based on markdown files in the selected category folder
|
21 |
+
pages_path = os.path.join(docs_base_path, category)
|
22 |
+
pages = [f for f in os.listdir(pages_path) if os.path.isfile(os.path.join(pages_path, f))]
|
23 |
+
page = st.sidebar.selectbox('Select a Page', pages)
|
24 |
+
|
25 |
+
# Load and display the selected markdown file
|
26 |
+
markdown_path = os.path.join(pages_path, page)
|
27 |
+
markdown_content = load_markdown_file(markdown_path)
|
28 |
+
st.markdown(markdown_content, unsafe_allow_html=True)
|