memegen.routes.latest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 25
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 2

1 Function

Rating   Name   Duplication   Size   Complexity  
A get() 0 14 2
1 1
from flask import Blueprint, render_template, current_app, make_response
0 ignored issues
show
introduced by
Unable to import 'flask'
Loading history...
2 1
from webargs import fields, flaskparser
0 ignored issues
show
introduced by
Unable to import 'webargs'
Loading history...
3
4 1
from ._utils import route
5
6
REFRESH_SECONDS = 60
7 1
8
blueprint = Blueprint('latest-page', __name__)
9
10 1
11 1
@blueprint.route("/latest")
12
@flaskparser.use_kwargs({'nsfw': fields.Bool(missing=False)})
13 1
def get(nsfw):
14 1
    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