Make a nice table and clean up.

This commit is contained in:
Matt
2020-05-19 21:47:57 -05:00
parent 5bcbe107af
commit 1515db776e
3 changed files with 29 additions and 9 deletions

14
app.py
View File

@ -2,6 +2,7 @@
from flask import Flask, jsonify, abort, make_response, request, render_template
from flask_httpauth import HTTPBasicAuth
import datetime
import humanfriendly
auth = HTTPBasicAuth()
@ -49,13 +50,16 @@ def create_status():
return jsonify({'status': status}), 201
@app.route('/', methods=['GET'])
def get_statuses():
@app.route('/raw', methods=['GET'])
def get_statuses_raw():
return jsonify({'statuses': statuses[::-1]})
@app.route('/list', methods=['GET'])
def list():
return render_template("list.html", statuses = statuses[::-1])
@app.route('/', methods=['GET'])
def get_statuses():
long_agos = [humanfriendly.format_timespan(datetime.datetime.now().timestamp() - status['timestamp']) for status in statuses[::-1]]
return render_template("list.html",
statuses = statuses[::-1],
long_agos = long_agos)
@app.errorhandler(404)

3
static/css/style.css Normal file
View File

@ -0,0 +1,3 @@
.statuses tr td {
border: 1px solid black;
}

View File

@ -1,6 +1,19 @@
<ul class="statuses">
<html>
<head>
<link href="/static/css/style.css" rel="stylesheet">
</head>
<body>
<table class = "statuses">
<tr><th>What Happened?</th><th>When Did It Happen?</th><th>How Long Has It Been?</th></tr>
{% for status in statuses %}
<li> {{ status.title }}
</li>
<tr>
<td>{{ status.title }}</td><td>{{ status.timestamp_readable }}</td><td>{{ long_agos[loop.index0] }}</td>
</tr>
{% endfor %}
</ul>
</table>
</body>
</html>