-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
202 lines (185 loc) · 6.03 KB
/
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
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
import streamlit as st
import calendar
from datetime import datetime
from PIL import Image
import base64
from io import BytesIO
from pages.cookie_manager import cookies
st.set_option('client.showErrorDetails', False)
def image_to_base64(image):
buffered = BytesIO()
image.save(buffered, format="PNG")
img_str = base64.b64encode(buffered.getvalue()).decode("utf-8")
return img_str
def main_page():
st.markdown(
f"""
<style>
.stApp {{
background-color: "#e93109";
}}
</style>
""",
unsafe_allow_html=True
)
# "#FFFFFF"
# today = datetime.today()
# year, month = today.year, today.month
# cal = calendar.Calendar()
# days = cal.itermonthdays(year, month)
# calendar_html = f"""
# <div class="calendar">
# <div class="calendar-header">
# <span><</span>
# <span>{calendar.month_name[month]} {year}</span>
# <span class = "nav">></span>
# </div>
# <div class="calendar-days">
# """
# # Add weekdays header
# for weekday in calendar.day_abbr:
# calendar_html += f"<div class='day-header'>{weekday}</div>"
# # Add days of the month
# for day in days:
# if day == 0: # Empty cells for days outside the current month
# calendar_html += "<div class='day empty'></div>"
# else:
# class_name = "day"
# if day == today.day and month == today.month and year == today.year:
# class_name += " selected"
# calendar_html += f"<div class='{class_name}'>{day}</div>"
# calendar_html += "</div></div>" # Close the calendar grid and container
# image_path = "main_page.png"
# with open(image_path, "rb") as image_file:
# encoded_image = base64.b64encode(image_file.read()).decode("utf-8")
# # HTML + CSS for the calendar
# html_code = f"""
# <!DOCTYPE html>
# <html lang="en">
# <head>
# <meta charset="UTF-8">
# <meta name="viewport" content="width=device-width, initial-scale=1.0">
# <title>Draw Your Day</title>
# <style>
# body {{
# margin: 0;
# padding: 0;
# font-family: 'Arial', sans-serif;
# display: flex;
# justify-content: center;
# align-items: center;
# height: 100vh;
# background: url('data:image/png;base64,{encoded_image});
# background-size: cover;
# }}
# .container {{
# text-align: center;
# background: rgba(255, 255, 255, 0.8);
# padding: 30px;
# border-radius: 15px;
# box-shadow: 0px 4px 20px rgba(0, 0, 0, 0.2);
# max-width: 600px;
# }}
# h1 {{
# font-size: 3em;
# color: #333;
# margin-bottom: 10px;
# }}
# p {{
# font-size: 1.2em;
# color: #555;
# margin-bottom: 30px;
# }}
# .calendar {{
# display: inline-block;
# width: 100%;
# background: white;
# border-radius: 10px;
# grid-template-columns: repeat(7, 1fr);
# padding: 20px;
# box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.1);
# }}
# .calendar-header {{
# display: flex;
# justify-content: space-between;
# align-items: center;
# margin-bottom: 20px;
# font-size: 1.2em;
# color: #333;
# }}
# .calendar-days {{
# display: grid;
# grid-template-columns: repeat(7, 1fr);
# gap: 5px;
# }}
# .day-header {{
# font-size: 0.9em;
# font-weight: bold;
# color: #666;
# text-align: center;
# }}
# .day {{
# width: 40px;
# height: 40px;
# display: flex;
# justify-content: center;
# align-items: center;
# font-size: 1em;
# color: #333;
# background: #f9f9f9;
# border-radius: 5px;
# cursor: pointer;
# }}
# .day.empty {{
# background: none;
# cursor: default;
# }}
# .day:hover {{
# background: #d3d3d3;
# }}
# .day.selected {{
# background: #333;
# color: white;
# }}
# </style>
# </head>
# <body>
# <div class="container">
# <h1>Draw Your Day</h1>
# <p>Please tell me how was your day. <br>Then I will draw and archive for you</p>
# {calendar_html}
# </div>
# </body>
# </html>
# """
# # Streamlit component
# st.components.v1.html(html_code, height=800, scrolling = False)
st.image("mainpage.png", width = 800)
if "logged_in" not in st.session_state:
if cookies.get("logged_in") is None:
st.session_state.logged_in = False
else:
st.session_state.logged_in = cookies.get("logged_in") == "True"
st.session_state.jwt_token = cookies.get("jwt_token")
if st.session_state.logged_in:
pages = {
"Menu": [
st.Page(main_page, title="Main"),
st.Page("pages/diary_list.py", title="List"),
st.Page("pages/diary_new.py", title="New"),
],
"Account": [
st.Page("pages/logout.py", title="Logout"),
],
}
else:
pages = {
"Menu":[
st.Page(main_page, title="Main")
],
"Account": [
st.Page("pages/login.py", title="Login/Register"),
]
}
pg = st.navigation(pages)
pg.run()