fix: Add null check for headers
All checks were successful
Build Docker / BuildImage (push) Successful in 28s
All checks were successful
Build Docker / BuildImage (push) Successful in 28s
This commit is contained in:
parent
6c004d14bd
commit
99b63592d0
31
server.py
31
server.py
@ -359,21 +359,22 @@ def index():
|
|||||||
loaded = True
|
loaded = True
|
||||||
|
|
||||||
# Check if crawler
|
# Check if crawler
|
||||||
if "Googlebot" not in request.headers.get(
|
if request.headers:
|
||||||
"User-Agent"
|
if "Googlebot" not in request.headers.get(
|
||||||
) and "Bingbot" not in request.headers.get("User-Agent"):
|
"User-Agent"
|
||||||
# Check if cookie is set
|
) and "Bingbot" not in request.headers.get("User-Agent"):
|
||||||
if not request.cookies.get("loaded") and not loaded:
|
# Check if cookie is set
|
||||||
# Set cookie
|
if not request.cookies.get("loaded") and not loaded:
|
||||||
resp = make_response(
|
# Set cookie
|
||||||
render_template("loading.html").replace(
|
resp = make_response(
|
||||||
"https://nathan.woodburn.au/loading", "https://nathan.woodburn.au/"
|
render_template("loading.html").replace(
|
||||||
),
|
"https://nathan.woodburn.au/loading", "https://nathan.woodburn.au/"
|
||||||
200,
|
),
|
||||||
{"Content-Type": "text/html"},
|
200,
|
||||||
)
|
{"Content-Type": "text/html"},
|
||||||
resp.set_cookie("loaded", "true", max_age=604800)
|
)
|
||||||
return resp
|
resp.set_cookie("loaded", "true", max_age=604800)
|
||||||
|
return resp
|
||||||
|
|
||||||
global handshake_scripts
|
global handshake_scripts
|
||||||
global projects
|
global projects
|
||||||
|
Loading…
Reference in New Issue
Block a user