memegen.routes.custom.get()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 13
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 12
nop 2
dl 0
loc 13
rs 9.8
c 0
b 0
f 0
1
from flask import Blueprint, render_template, current_app, make_response
2
from webargs import fields, flaskparser
3
4
from . image import PLACEHOLDER
5
6
7
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