def do_POST(self) -> None:
# pylint: disable=invalid-name,missing-function-docstring
+ if self.pagename == 'reload':
+ self.server.load()
self.redirect(Path(''))
def do_GET(self) -> None:
def __init__(self, path_dat: Path, *args, **kwargs) -> None:
super().__init__(PATH_TEMPLATES, (SERVER_HOST, SERVER_PORT), Handler)
+ self._path_dat = path_dat
+ self.load()
+
+ def load(self) -> None:
+ """Read into ledger file at .path_dat."""
self.dat_lines = [
- DatLine(line)
- for line in path_dat.read_text(encoding='utf8').splitlines()]
+ DatLine(line)
+ for line in self._path_dat.read_text(encoding='utf8').splitlines()]
self.bookings: list[Booking] = []
booking_lines: list[DatLine] = []
last_date = ''
</style>
</head>
<body>
-<a href="/">home</a> · <a href="/raw">raw</a> · <a href="/balance">balance</a>
+<form action="/reload" method="POST">
+<a href="/">home</a> · <a href="/raw">raw</a> · <a href="/balance">balance</a> · <input type="submit" value="reload" />
+</form>
<hr />
{% block content %}{% endblock %}
</body>
{% endblock %}
{% block content %}
-<form action="/" method="POST"><input type="submit" value="A" /></form>
-<form action="/" method="GET"><input type="submit" value="B" /></form>
-<hr/>
{{ macros.table_dat_lines(dat_lines, single=false, raw=false) }}
{% endblock %}