Download app.py from abuzarAli/Todo_App: direct link, hf CLI and curl.
- Browser
- Download file 941 Bytes
-
https://huggingface.co/spaces/abuzarAli/Todo_App/resolve/main/app.py
- Command line
-
hf download hf://spaces/abuzarAli/Todo_App/app.py
-
curl -L -o app.py https://huggingface.co/spaces/abuzarAli/Todo_App/resolve/main/app.py
941 Bytes
| import streamlit as st | |
| import pandas as pd | |
| # Initialize a session state for tasks | |
| if 'tasks' not in st.session_state: | |
| st.session_state.tasks = [] | |
| # Function to add a task | |
| def add_task(task): | |
| st.session_state.tasks.append(task) | |
| # Function to delete a task | |
| def delete_task(task): | |
| st.session_state.tasks.remove(task) | |
| # Streamlit UI | |
| st.title("To-Do App") | |
| # Displaying the list of tasks | |
| if st.session_state.tasks: | |
| st.subheader("Your Tasks") | |
| for task in st.session_state.tasks: | |
| task_col, del_col = st.columns([8, 1]) | |
| task_col.write(task) | |
| if del_col.button("Delete", key=task): | |
| delete_task(task) | |
| else: | |
| st.write("No tasks yet. Add a task below!") | |
| # Add new task | |
| task_input = st.text_input("Add a new task") | |
| if st.button("Add Task"): | |
| if task_input: | |
| add_task(task_input) | |
| st.success("Task added successfully!") | |
| else: | |
| st.warning("Please enter a task.") | |