This is a simple Todo application built using Flask, Bootstrap, Jinja, SQLite, and SQLAlchemy.
You can try out the application by visiting the following link: Todo App Demo
-
Clone the repository:
git clone https://github.com/SinkuKumar/ToDo.git
-
Change to the project directory:
cd ToDo
-
Create a virtual environment (optional but recommended):
python3 -m venv env source env/bin/activate
-
Install the required dependencies:
pip install -r requirements.txt
-
Start the Flask development server:
flask run
-
Open your web browser and visit
http://localhost:815
to access the Todo app.
- Add new tasks: Enter a task in the input field and press Enter or click the "Add" button.
- Mark tasks as completed: Click on a task to toggle its completion status.
- Delete tasks: Click on the trash bin icon to remove a task from the list.
The application uses a SQLite database named todos.db
to store the tasks. The Todo
table in the database has the following columns:
-
id
: Integer (primary key) -
task
: String (200 characters, non-null) -
completed
: Boolean (default: False) -
timestamp
: String (20 characters, default: current date and time)
- The
app
object is created using Flask and theSQLALCHEMY_DATABASE_URI
configuration is set to use the SQLite databasetodos.db
. - The
Todo
class represents a Todo item and defines the structure of theTodo
table in the database. - The
index
route handles both GET and POST requests. For GET requests, it retrieves all the todos from the database and renders theindex.html
template with the todos. For POST requests, it adds a new todo to the database and redirects to the index page. - The
delete
route handles the deletion of a todo item. It retrieves the todo with the givenid
from the database and deletes it. Then, it redirects to the index page. - The
update
route handles updating the completion status of a todo item. It retrieves the todo with the givenid
from the database, toggles itscompleted
attribute, and saves the changes. Then, it redirects to the index page.
The application uses the following templates located in the templates
directory:
-
index.html
: Displays the list of todos. It includes a form to add new todos and shows the existing todos with options to mark them as completed or delete them.
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for more information.