Total Complexity | 1 |
Total Lines | 29 |
Duplicated Lines | 0 % |
Coverage | 75% |
Changes | 0 |
1 | 1 | from flask import Blueprint, render_template, current_app, make_response |
|
|
|||
2 | from webargs import fields, flaskparser |
||
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 |