memegen.routes.custom   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 29
rs 10
c 0
b 0
f 0
ccs 3
cts 4
cp 0.75
wmc 1

1 Function

Rating   Name   Duplication   Size   Complexity  
A get() 0 13 1
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
from webargs import fields, flaskparser
0 ignored issues
show
introduced by
Unable to import 'webargs'
Loading history...
3
4 1
from . image import PLACEHOLDER
5
6
7 1
OPTIONS = {
8
    'font': fields.Str(missing='titilliumweb-black'),
9
    'image': fields.URL(missing=PLACEHOLDER),
10
}
11
12
13
blueprint = Blueprint('custom-page', __name__)
14
15
16
@blueprint.route("/custom")
17
@flaskparser.use_kwargs(OPTIONS)
18
def get(font, image):
19
    html = render_template(
20
        'custom.html',
21
        fonts=sorted(current_app.font_service.all()),
22
        font=font,
23
        image=image,
24
        config=current_app.config,
25
    )
26
    response = make_response(html)
27
    response.headers['Cache-Control'] = f'max-age={60*60*24*7}'
28
    return response
29