slimshadow commited on
Commit
3782715
·
verified ·
1 Parent(s): ea06ea3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -46
app.py CHANGED
@@ -1,58 +1,21 @@
1
  import streamlit as st
2
- import streamlit.components.v1 as components
3
 
4
  # Define subjects and file paths
5
  subjects = {
6
  "Architecture": "architecture.md",
7
  "Data Structures": "DS.md",
8
- "Operating Systems": "os.md",
9
  "Mathematics": "maths.md",
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.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.")
 
1
  import streamlit as st
 
2
 
3
  # Define subjects and file paths
4
  subjects = {
5
  "Architecture": "architecture.md",
6
  "Data Structures": "DS.md",
7
+ "Operating Systems": "advanceos.md",
8
  "Mathematics": "maths.md",
9
  "C++": "cplusplus.md"
10
  }
11
 
12
+ # Display the navbar at the top
13
+ st.title("Course Syllabus")
14
+ subject = st.radio("Select a subject:", list(subjects.keys()), horizontal=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
+ # Load and display content based on selection
17
+ with open(subjects[subject], "r") as file:
18
+ syllabus_content = file.read()
19
 
20
+ # Render the content
21
+ st.markdown(syllabus_content, unsafe_allow_html=True)