-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBook_Tracker.py
115 lines (106 loc) · 4.87 KB
/
Book_Tracker.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import streamlit as st
import pandas as pd
st.set_page_config(page_icon="📑", page_title="Book Tracker - Ziaul Karim")
def check_password():
def password_entered():
"""Checks whether a password entered by the user is correct."""
if (
st.session_state["username"] in st.secrets["passwords"] # if username is included in secrets file
and st.session_state["password"]
== st.secrets["passwords"][st.session_state["username"]] # if password under the username is matching the one given
):
st.session_state["password_correct"] = True # if those conditions are met then our password is correct
del st.session_state["password"] # delete the password from session state
del st.session_state["username"] # delete the username from session state
else:
st.session_state["password_correct"] = False
if "password_correct" not in st.session_state:
# First run, show inputs for username + password.
st.title("Book Tracker 📔")
st.header("Login 👤")
st.text_input("Username 👤", on_change=password_entered, key="username")
st.text_input(
"Password 🔑", type="password", on_change=password_entered, key="password"
)
return False
elif not st.session_state["password_correct"]:
# Password not correct, show input + error.
st.header("Login")
st.text_input("Username 👤", on_change=password_entered, key="username")
st.text_input(
"Password 🔑", type="password", on_change=password_entered, key="password"
)
st.error("😕 User not known or password incorrect")
return False
else:
# Password correct.
return True
def main():
st.title('📑My Book Tracker')
st.image('./giphy.gif')
st.sidebar.header('📑 My Book Tracker')
st.markdown('I track my books here. That\'s it.')
import datetime
# Get the current year
current_year = datetime.datetime.now().year
# Include the current year in the footer
footer = f'© {current_year} Copyright | Made by <a href="https://ziaulkarim.netlify.app" >Md. Ziaul Karim</a>'
hide_streamlit_style = f"""<div class="myFooter">{footer}</a> </div>
"""
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
if __name__=='__main__':
if check_password():
st.success("Logged in!!!")
hide_streamlit_style = """
<head>
<style>
#MainMenu{visibility: hidden;}
.css-fk4es0{display:none;}
.css-1lsmgbg {display: none;}
.myFooter{color:rgba(250, 250, 250, 0.6); margin-top: 150px; text-align: center;}
.myFooter a{color: rgb(255, 75, 75); font-weight: bolder;}
.css-10trblm{color:rgb(255, 75, 75); text-align:center;}
.css-16huue1 {color:rgb(255, 75, 75); font-size:18px;}
.css-v37k9u p{color:#edf5e1; font-size: 18px;}
.css-1q8dd3e{color:rgb(255, 75, 75);}
.css-1q8dd3e:hover{color:#edf5e1; border-color:rgb(255, 75, 75);}
.css-17ziqus {background-color: brown; display:block}
p{text-align: center;}
body{text-align: center;}
.css-1kyxreq{display:block; display:block;}
.css-fblp2m {display:block;}
.css-1rs6os {display:block;}
</style>
<title> Book Tracker </title>
</head>
"""
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
if 'df' not in st.session_state:
st.session_state.df = pd.read_csv('./data/data.csv')
df = st.session_state.df
main()
else:
hide_streamlit_style = """
<head>
<style>
#MainMenu{visibility: hidden;}
.css-fk4es0{display:none;}
.css-1lsmgbg {display: none;}
.myFooter{color:rgba(250, 250, 250, 0.6); margin-top: 150px; text-align: center;}
.myFooter a{color: rgb(255, 75, 75); font-weight: bolder;}
.css-10trblm{color:rgb(255, 75, 75); text-align:center;}
.css-16huue1 {color:rgb(255, 75, 75); font-size:18px;}
.css-v37k9u p{color:#edf5e1; font-size: 18px;}
.css-1q8dd3e{color:rgb(255, 75, 75);}
.css-1q8dd3e:hover{color:#edf5e1; border-color:rgb(255, 75, 75);}
.css-17ziqus {background-color: brown; display: none!important;}
.css-fblp2m {display:none;}
.css-1rs6os {display:none}
p{text-align: center;}
body{text-align: center;}
.css-1kyxreq{display:block;}
</style>
<title> Book Tracker </title>
</head>
"""
st.markdown(hide_streamlit_style, unsafe_allow_html=True)