Total Complexity | 2 |
Total Lines | 25 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | from flask import Blueprint, render_template, current_app, make_response |
||
2 | from webargs import fields, flaskparser |
||
3 | |||
4 | from ._utils import route |
||
5 | |||
6 | REFRESH_SECONDS = 60 |
||
7 | |||
8 | blueprint = Blueprint('latest-page', __name__) |
||
9 | |||
10 | |||
11 | @blueprint.route("/latest") |
||
12 | @flaskparser.use_kwargs({'nsfw': fields.Bool(missing=False)}) |
||
13 | def get(nsfw): |
||
14 | filtered = 'false' if nsfw else 'true' |
||
15 | html = render_template( |
||
16 | 'latest.html', |
||
17 | srcs=[route('image.get_latest', index=i, filtered=filtered) |
||
18 | for i in range(24)], |
||
19 | refresh=REFRESH_SECONDS, |
||
20 | config=current_app.config, |
||
21 | ) |
||
22 | response = make_response(html) |
||
23 | response.headers['Cache-Control'] = f'max-age={REFRESH_SECONDS-1}' |
||
24 | return response |
||
25 |