ArthurFischel commited on
Commit
287969e
1 Parent(s): 8a983b3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -2
app.py CHANGED
@@ -1,15 +1,43 @@
1
  import streamlit as st
2
 
3
-
4
  def read_readme():
5
  with open("README.md", "r") as f:
6
  readme_content = f.read()
 
 
 
 
 
 
 
 
 
 
 
7
  return readme_content
8
 
 
 
 
 
 
9
 
10
  def main():
11
  readme_content = read_readme()
12
- st.markdown(readme_content)
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
 
15
  if __name__ == "__main__":
 
1
  import streamlit as st
2
 
 
3
  def read_readme():
4
  with open("README.md", "r") as f:
5
  readme_content = f.read()
6
+
7
+ # Find the start and end of the block to remove
8
+ start_marker = "---\n"
9
+ end_marker = "\n---"
10
+ start_index = readme_content.find(start_marker)
11
+ end_index = readme_content.find(end_marker) + len(end_marker)
12
+
13
+ # Remove the block if found
14
+ if start_index != -1 and end_index != -1:
15
+ readme_content = readme_content[:start_index] + readme_content[end_index:]
16
+
17
  return readme_content
18
 
19
+ def create_pages(content):
20
+ pages = content.split("# ")
21
+ # Remove the first element as it contains the intro
22
+ intro = pages.pop(0)
23
+ return intro, pages
24
 
25
  def main():
26
  readme_content = read_readme()
27
+ intro, pages = create_pages(readme_content)
28
+
29
+ st.title("Welcome to My Blog")
30
+ st.markdown(intro)
31
+
32
+ st.sidebar.title("Sections")
33
+ for index, page in enumerate(pages):
34
+ page_title = page.split("\n", 1)[0]
35
+ st.sidebar.markdown(f"[{page_title}](#{index})")
36
+
37
+ for index, page in enumerate(pages):
38
+ st.markdown(f"## {page}")
39
+ st.markdown(page, unsafe_allow_html=True)
40
+ st.sidebar.markdown(f"[Back to Top](#{index})")
41
 
42
 
43
  if __name__ == "__main__":