forked from streamlit/30days
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstreamlit_app.py
67 lines (54 loc) · 2.51 KB
/
streamlit_app.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import streamlit as st
import os
import numpy as np
import pandas as pd
import urllib.request
from PIL import Image
import glob
def update_params():
st.experimental_set_query_params(challenge=st.session_state.day)
md_files = sorted([int(x.strip('Day').strip('.md')) for x in glob.glob1('content',"*.md") ])
# Logo and Navigation
col1, col2, col3 = st.columns((1,4,1))
with col2:
st.image(Image.open('streamlit-logo-secondary-colormark-darktext.png'))
st.markdown('# 30 Days of Streamlit')
days_list = [f'Day {x}' for x in md_files]
query_params = st.experimental_get_query_params()
if query_params and query_params["challenge"][0] in days_list:
st.session_state.day = query_params["challenge"][0]
selected_day = st.selectbox('Start the Challenge 👇', days_list, key="day", on_change=update_params)
with st.expander("About the #30DaysOfStreamlit"):
st.markdown('''
The **#30DaysOfStreamlit** is a coding challenge designed to help you get started in building Streamlit apps.
Particularly, you'll be able to:
- Set up a coding environment for building Streamlit apps
- Build your first Streamlit app
- Learn about all the awesome input/output widgets to use for your Streamlit app
''')
# Sidebar
st.sidebar.header('About')
st.sidebar.markdown('[Streamlit](https://streamlit.io) is a Python library that allows the creation of interactive, data-driven web applications in Python.')
st.sidebar.header('Resources')
st.sidebar.markdown('''
- [Streamlit Documentation](https://docs.streamlit.io/)
- [Cheat sheet](https://docs.streamlit.io/library/cheatsheet)
- [Book](https://www.amazon.com/dp/180056550X) (Getting Started with Streamlit for Data Science)
- [Blog](https://blog.streamlit.io/how-to-master-streamlit-for-data-science/) (How to master Streamlit for data science)
''')
st.sidebar.header('Deploy')
st.sidebar.markdown('You can quickly deploy Streamlit apps using [Streamlit Cloud](https://streamlit.io/cloud) in just a few clicks.')
# Display content
for i in days_list:
if selected_day == i:
st.markdown(f'# 🗓️ {i}')
j = i.replace(' ', '')
with open(f'content/{j}.md', 'r') as f:
st.markdown(f.read())
if os.path.isfile(f'content/figures/{j}.csv') == True:
st.markdown('---')
st.markdown('### Figures')
df = pd.read_csv(f'content/figures/{j}.csv', engine='python')
for i in range(len(df)):
st.image(f'content/images/{df.img[i]}')
st.info(f'{df.figure[i]}: {df.caption[i]}')