Store value request.is_localhost and pass request into all jinjas.

master
voussoir 2021-02-25 18:52:25 -08:00
parent 27771f5763
commit 361795237c
No known key found for this signature in database
GPG Key ID: 5F7554F8C26DACCB
1 changed files with 3 additions and 1 deletions

View File

@ -78,7 +78,8 @@ site.route = decorate_and_route
@site.before_request
def before_request():
ip = request.remote_addr
if site.localhost_only and ip != '127.0.0.1':
request.is_localhost = ip == '127.0.0.1'
if site.localhost_only and not request.is_localhost:
flask.abort(403)
gzip_minimum_size = 500 * bytestring.BYTE
@ -213,6 +214,7 @@ def render_template(request, template_name, **kwargs):
response = flask.render_template(
template_name,
request=request,
session=session,
theme=theme,
**kwargs,