Upload 2 files
Browse files- app.py +81 -0
- requirements.txt +2 -0
app.py
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import sqlite3
|
| 3 |
+
from datetime import datetime
|
| 4 |
+
|
| 5 |
+
# Initialize Database
|
| 6 |
+
def init_db():
|
| 7 |
+
conn = sqlite3.connect("tasks.db")
|
| 8 |
+
c = conn.cursor()
|
| 9 |
+
c.execute('''CREATE TABLE IF NOT EXISTS tasks (
|
| 10 |
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
| 11 |
+
task TEXT NOT NULL,
|
| 12 |
+
status TEXT NOT NULL,
|
| 13 |
+
date TEXT NOT NULL)''')
|
| 14 |
+
conn.commit()
|
| 15 |
+
conn.close()
|
| 16 |
+
|
| 17 |
+
# Add Task
|
| 18 |
+
def add_task(task, status, date):
|
| 19 |
+
conn = sqlite3.connect("tasks.db")
|
| 20 |
+
c = conn.cursor()
|
| 21 |
+
c.execute("INSERT INTO tasks (task, status, date) VALUES (?, ?, ?)", (task, status, date))
|
| 22 |
+
conn.commit()
|
| 23 |
+
conn.close()
|
| 24 |
+
|
| 25 |
+
# Get Tasks by Status
|
| 26 |
+
def get_tasks_by_status(status):
|
| 27 |
+
conn = sqlite3.connect("tasks.db")
|
| 28 |
+
c = conn.cursor()
|
| 29 |
+
c.execute("SELECT * FROM tasks WHERE status = ?", (status,))
|
| 30 |
+
tasks = c.fetchall()
|
| 31 |
+
conn.close()
|
| 32 |
+
return tasks
|
| 33 |
+
|
| 34 |
+
# Get Tasks by Date
|
| 35 |
+
def get_tasks_by_date(date):
|
| 36 |
+
conn = sqlite3.connect("tasks.db")
|
| 37 |
+
c = conn.cursor()
|
| 38 |
+
c.execute("SELECT * FROM tasks WHERE date = ?", (date,))
|
| 39 |
+
tasks = c.fetchall()
|
| 40 |
+
conn.close()
|
| 41 |
+
return tasks
|
| 42 |
+
|
| 43 |
+
# UI Layout
|
| 44 |
+
st.set_page_config(page_title="Construction To-Do List", layout="centered")
|
| 45 |
+
st.markdown("""
|
| 46 |
+
<style>
|
| 47 |
+
body {background-color: #f4f4f4;}
|
| 48 |
+
.stTextInput>div>div>input {border-radius: 10px; padding: 10px; border: 1px solid #ccc;}
|
| 49 |
+
.stButton>button {background-color: #007BFF; color: white; border-radius: 10px; padding: 10px;}
|
| 50 |
+
</style>
|
| 51 |
+
""", unsafe_allow_html=True)
|
| 52 |
+
|
| 53 |
+
st.title("🛠️ Construction Program Manager - To-Do List")
|
| 54 |
+
init_db()
|
| 55 |
+
|
| 56 |
+
# Task Input
|
| 57 |
+
with st.form("task_form"):
|
| 58 |
+
task = st.text_input("Task Description:")
|
| 59 |
+
status = st.selectbox("Status:", ["Pending", "In Progress", "Completed"])
|
| 60 |
+
date = st.date_input("Task Date:")
|
| 61 |
+
submit = st.form_submit_button("Add Task")
|
| 62 |
+
|
| 63 |
+
if submit and task:
|
| 64 |
+
add_task(task, status, str(date))
|
| 65 |
+
st.success("Task Added Successfully!")
|
| 66 |
+
|
| 67 |
+
# Task Filtering
|
| 68 |
+
st.subheader("📌 View Tasks")
|
| 69 |
+
selected_status = st.selectbox("Filter by Status:", ["All", "Pending", "In Progress", "Completed"])
|
| 70 |
+
selected_date = st.date_input("Filter by Date:")
|
| 71 |
+
|
| 72 |
+
if selected_status != "All":
|
| 73 |
+
tasks = get_tasks_by_status(selected_status)
|
| 74 |
+
else:
|
| 75 |
+
tasks = get_tasks_by_date(str(selected_date))
|
| 76 |
+
|
| 77 |
+
if tasks:
|
| 78 |
+
for t in tasks:
|
| 79 |
+
st.write(f"**Task:** {t[1]} | **Status:** {t[2]} | **Date:** {t[3]}")
|
| 80 |
+
else:
|
| 81 |
+
st.info("No tasks found.")
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
sqlite3
|