fixups
This commit is contained in:
parent
c2afc3654c
commit
b66cdea753
8 changed files with 18 additions and 9 deletions
1
a5/.gitignore
vendored
Normal file
1
a5/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
__pycache__
|
||||
2
a5/db.py
2
a5/db.py
|
|
@ -84,7 +84,7 @@ CREATE TABLE IF NOT EXISTS measurements
|
|||
cursor.execute(
|
||||
# sql
|
||||
"SELECT timestamp, tvoc, co2 FROM measurements ORDER BY timestamp DESC LIMIT ?, ?",
|
||||
(page_size, page * page_size),
|
||||
(page_size, (page - 1) * page_size),
|
||||
)
|
||||
return cursor.fetchall()
|
||||
|
||||
|
|
|
|||
BIN
a5/greetings.db
Normal file
BIN
a5/greetings.db
Normal file
Binary file not shown.
|
|
@ -28,7 +28,7 @@ def report() -> ResponseReturnValue:
|
|||
return "ok", 200
|
||||
|
||||
|
||||
@app.route("/stats", methods=["GET"])
|
||||
@app.route("/", methods=["GET"])
|
||||
def stats() -> ResponseReturnValue:
|
||||
"""Gets overall statistics as well as few recent measurements"""
|
||||
db = get_db()
|
||||
|
|
@ -45,7 +45,7 @@ def measurements() -> ResponseReturnValue:
|
|||
"""Lists measurements"""
|
||||
db = get_db()
|
||||
page_size = 20
|
||||
page = request.args["page"]
|
||||
page = request.args["page"] if "page" in request.args else 1
|
||||
try:
|
||||
page = int(page)
|
||||
if page < 0:
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@
|
|||
{% endfor %}
|
||||
|
||||
<div>
|
||||
{% if has_next_page %}
|
||||
{% if page > 1 %}
|
||||
<a href="/measurements?page={{page+1}}" class="btn btn-link">Previous page</a>
|
||||
{% endif %}
|
||||
{% if page > 0 %}
|
||||
{% if has_next_page %}
|
||||
<a href="/measurements?page={{page-1}}" class="btn btn-link">Next page</a>
|
||||
{% endif %}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{% extends "../base.html.j2" %}
|
||||
{% extends "base.html.j2" %}
|
||||
{% block title %}Overview{% endblock %}
|
||||
{% block description %}Overview of a CO2 and TVOC sensor data.{% endblock %}
|
||||
{% block content %}
|
||||
{% include "../block/index.html.j2" %}
|
||||
{% include "block/index.html.j2" %}
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{% extends "../base.html.j2" %}
|
||||
{% extends "base.html.j2" %}
|
||||
{% block title %}Measurements{% endblock %}
|
||||
{% block description %}List of measurements{% endblock %}
|
||||
{% block content %}
|
||||
{% include "../block/measurements.html.j2" %}
|
||||
{% include "block/measurements.html.j2" %}
|
||||
{% endblock %}
|
||||
|
|
|
|||
8
a5/uv.lock
Normal file
8
a5/uv.lock
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
version = 1
|
||||
revision = 3
|
||||
requires-python = ">=3.13"
|
||||
|
||||
[[package]]
|
||||
name = "a5"
|
||||
version = "0.1.0"
|
||||
source = { virtual = "." }
|
||||
Loading…
Reference in a new issue