Newer
Older
@app.route('/_warmup')
def warmup():
fetch_news_items()
fetch_events()
for supporter in fetch_supporters():
hash = hashlib.md5(supporter['email'].encode('utf-8')).hexdigest()
try:
fetch_gravatar(
hash, s='198', d=gravatar.default, r=gravatar.rating)
except Exception:
app.logger.warning('fail to fetch gravatar')
for path in glob.glob(os.path.join(app.static_folder, '**/*.webp')):
dominant_color(os.path.relpath(path, app.static_folder))
return '', HTTPStatus.NO_CONTENT
@cache.cached(key_prefix=cache_key_prefix_view)
@add_links(PRECONNECT_HEADERS + JS_LINK_HEADERS + CSS_LINK_HEADERS)
return render_template(
'not_found.html', canonical=None), HTTPStatus.NOT_FOUND
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
class RequestFormatter(logging.Formatter):
def format(self, record):
record.url = request.url
record.remote_addr = request.remote_addr
return super().format(record)
mail_handler = SMTPHandler(
mailhost='mx.tryton.org',
fromaddr='www@tryton.org',
toaddrs=['webmaster@tryton.org'],
subject="[www.tryton.org] Application Error",
)
mail_handler.setLevel(logging.ERROR)
formatter = RequestFormatter(
'[%(asctime)s] %(remote_addr)s requested %(url)s\n'
'%(levelname)s in %(module)s: %(message)s'
)
default_handler.setFormatter(formatter)
mail_handler.setFormatter(formatter)
app.config['CDN_DEBUG'] = ast.literal_eval(
os.environ.get('CDN_DEBUG', 'True'))
app.run(
debug=ast.literal_eval(os.environ.get('DEBUG', 'True')),
extra_files=[
'templates/*.html',
'templates/events/*.html',
'templates/guidelines/*.html',
'templates/service_providers/*.html',
'templates/success_stories/*.html',
if not app.debug:
app.logger.addHandler(mail_handler)