-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweb.py
38 lines (30 loc) · 1.04 KB
/
web.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
# terminal: streamlit run web.py -> selaimessa localhost sivu...
#
# deployment to cloud:
# - pip freeze > requirements.txt
# - in project (repository) only files: web.py, functions.py, todos.txt, requirements.txt, pages/about.py
# - streamlit local host sivulta -> deploy
# - login github tunnuksilla
import streamlit as st
import functions
todos = functions.get_todos()
# callback function
def add_todo():
todo = st.session_state["new_todo"]
print(todo)
todos.append(todo + "\n")
functions.write_todos(todos)
st.session_state["new_todo"] = ""
st.title("My Todo App")
st.subheader("This is my todo app")
st.write("This app is to increase your productivity")
for index, todo in enumerate(todos):
checkbox = st.checkbox(todo, key=todo)
if checkbox:
todos.pop(index)
functions.write_todos(todos)
del st.session_state[todo]
st.experimental_rerun()
st.text_input(label=" ", placeholder="Add new todo", on_change=add_todo, key='new_todo')
# for develoment and debugging purposes
# st.session_state