Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
|
| 3 |
# Define subjects and file paths
|
| 4 |
subjects = {
|
|
@@ -9,13 +10,49 @@ subjects = {
|
|
| 9 |
"C++": "cplusplus.md"
|
| 10 |
}
|
| 11 |
|
| 12 |
-
#
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
|
| 18 |
-
syllabus_content = file.read()
|
| 19 |
|
| 20 |
-
#
|
| 21 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import streamlit.components.v1 as components
|
| 3 |
|
| 4 |
# Define subjects and file paths
|
| 5 |
subjects = {
|
|
|
|
| 10 |
"C++": "cplusplus.md"
|
| 11 |
}
|
| 12 |
|
| 13 |
+
# Create custom HTML for navbar
|
| 14 |
+
nav_html = """
|
| 15 |
+
<style>
|
| 16 |
+
.navbar {
|
| 17 |
+
overflow: hidden;
|
| 18 |
+
background-color: #333;
|
| 19 |
+
position: fixed;
|
| 20 |
+
top: 0;
|
| 21 |
+
width: 100%;
|
| 22 |
+
z-index: 100;
|
| 23 |
+
display: flex;
|
| 24 |
+
justify-content: space-around;
|
| 25 |
+
}
|
| 26 |
+
.navbar a {
|
| 27 |
+
float: left;
|
| 28 |
+
display: block;
|
| 29 |
+
color: #f2f2f2;
|
| 30 |
+
text-align: center;
|
| 31 |
+
padding: 14px 16px;
|
| 32 |
+
text-decoration: none;
|
| 33 |
+
font-size: 17px;
|
| 34 |
+
}
|
| 35 |
+
.navbar a:hover {
|
| 36 |
+
background-color: #ddd;
|
| 37 |
+
color: black;
|
| 38 |
+
}
|
| 39 |
+
</style>
|
| 40 |
+
<div class="navbar">
|
| 41 |
+
"""
|
| 42 |
+
for subject in subjects.keys():
|
| 43 |
+
nav_html += f'<a href="/?nav={subject}">{subject}</a>'
|
| 44 |
+
nav_html += "</div><br><br><br>"
|
| 45 |
|
| 46 |
+
# Display the navbar
|
| 47 |
+
st.markdown(nav_html, unsafe_allow_html=True)
|
|
|
|
| 48 |
|
| 49 |
+
# Get selected subject from query params
|
| 50 |
+
subject = st.experimental_get_query_params().get("nav", ["Architecture"])[0]
|
| 51 |
+
|
| 52 |
+
# Load and display content
|
| 53 |
+
if subject in subjects:
|
| 54 |
+
with open(subjects[subject], "r") as file:
|
| 55 |
+
syllabus_content = file.read()
|
| 56 |
+
st.markdown(syllabus_content, unsafe_allow_html=True)
|
| 57 |
+
else:
|
| 58 |
+
st.write("Select a subject from the navbar.")
|