bridgy-fed/logs.py

32 wiersze
847 B
Python
Czysty Zwykły widok Historia

"""Render recent responses and logs."""
import calendar
import urllib.parse
from flask import render_template
from oauth_dropins.webutil import flask_util, logs, util
2021-07-13 15:06:35 +00:00
from app import app, cache
from models import Response
@app.get('/responses')
def responses():
"""Renders recent Responses, with links to logs."""
responses = Response.query().order(-Response.updated).fetch(20)
for r in responses:
r.source_link = util.pretty_link(r.source())
r.target_link = util.pretty_link(r.target())
2021-07-13 15:06:35 +00:00
r.log_url_path = '/log?' + urllib.parse.urlencode({
'key': r.key.id(),
'start_time': calendar.timegm(r.updated.timetuple()),
})
return render_template('responses.html', responses=responses)
2021-07-13 15:06:35 +00:00
@app.get('/log')
@flask_util.cached(cache, logs.CACHE_TIME)
2021-07-13 15:06:35 +00:00
def log():
return logs.log()