Your task for today is to build a Habit Tracker web application using Flask and object-oriented programming. You will design classes to represent habits and their streaks, and then connect them to a Flask interface so users can interact with the tracker through their browser. This project strengthens both your OOP design skills and your ability to create simple web apps with Flask.
📝 Project Task
The program should:
Define a
Habit
class with attributes:name
,streak
,last_done
.Define a
HabitTracker
class with methods to add habits, mark them as done, and view streaks.Build a Flask web app with routes to:
Show all habits and their streaks
Add a new habit via a form
Mark a habit as done for today
Bonus (optional):
Store habits persistently in a CSV or JSON file
Add Bootstrap styling for nicer UI
Display longest streaks or statistics
Expected Output
When running the app and opening it in the browser, you should see:
A homepage listing habits and streaks
A form to add a new habit
A button to mark each habit as done
Join the Python & AI Builders Skool Community
Got questions to ask the author about this project? Join our Python & AI builders community for weekly videos and discussions:
💻 Launch This Project in Colab
Open the interactive Google Colab notebook for today’s project — with full instructions, hints, and solutions.
Click the button below to start coding — no setup needed: