memegen.routes.latest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 2

1 Function

Rating   Name   Duplication   Size   Complexity  
A get() 0 14 2
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