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)