diff --git a/models/Habit.py b/models/Habit.py index 4b6c65e..221934d 100644 --- a/models/Habit.py +++ b/models/Habit.py @@ -1,3 +1,4 @@ +import json from dataclasses import dataclass from datetime import datetime @@ -108,3 +109,5 @@ class Habit: self.percentage = int(count / self.times * 100) + def to_json(self): + return json.dumps(self, default=lambda o: o.__dict__, sort_keys=True, indent=4) diff --git a/templates/index.html b/templates/index.html index f00d2ea..c61e2dc 100644 --- a/templates/index.html +++ b/templates/index.html @@ -89,9 +89,12 @@ -