feat: Check if user_agent is a crawler before showing loading page
All checks were successful
Build Docker / BuildImage (push) Successful in 45s
All checks were successful
Build Docker / BuildImage (push) Successful in 45s
This commit is contained in:
parent
6de2518f1f
commit
cdb7eb86a5
17
server.py
17
server.py
@ -67,6 +67,7 @@ def getAddress(coin: str) -> str:
|
|||||||
address = file.read()
|
address = file.read()
|
||||||
return address
|
return address
|
||||||
|
|
||||||
|
|
||||||
def find(name, path):
|
def find(name, path):
|
||||||
for root, dirs, files in os.walk(path):
|
for root, dirs, files in os.walk(path):
|
||||||
if name in files:
|
if name in files:
|
||||||
@ -341,14 +342,18 @@ def index():
|
|||||||
|
|
||||||
# Check if crawler
|
# Check if crawler
|
||||||
if (
|
if (
|
||||||
request.user_agent.browser != "Googlebot"
|
"Googlebot" not in request.user_agent.browser
|
||||||
and request.user_agent.browser != "Bingbot"
|
and "Bingbot" not in request.user_agent.browser
|
||||||
):
|
):
|
||||||
# Check if cookie is set
|
# Check if cookie is set
|
||||||
if not request.cookies.get("loaded") and not loaded:
|
if not request.cookies.get("loaded") and not loaded:
|
||||||
# Set cookie
|
# Set cookie
|
||||||
resp = make_response(
|
resp = make_response(
|
||||||
render_template("loading.html"), 200, {"Content-Type": "text/html"}
|
render_template("loading.html").replace(
|
||||||
|
"https://nathan.woodburn.au/loading", "https://nathan.woodburn.au/"
|
||||||
|
),
|
||||||
|
200,
|
||||||
|
{"Content-Type": "text/html"},
|
||||||
)
|
)
|
||||||
resp.set_cookie("loaded", "true", max_age=604800)
|
resp.set_cookie("loaded", "true", max_age=604800)
|
||||||
return resp
|
return resp
|
||||||
@ -610,6 +615,7 @@ def now_old():
|
|||||||
|
|
||||||
# endregion
|
# endregion
|
||||||
|
|
||||||
|
|
||||||
# region Donate
|
# region Donate
|
||||||
@app.route("/donate")
|
@app.route("/donate")
|
||||||
def donate():
|
def donate():
|
||||||
@ -756,8 +762,10 @@ def addressQR(data):
|
|||||||
# Return the QR code image as a response
|
# Return the QR code image as a response
|
||||||
return send_file(qr_image_path, mimetype="image/png")
|
return send_file(qr_image_path, mimetype="image/png")
|
||||||
|
|
||||||
|
|
||||||
# endregion
|
# endregion
|
||||||
|
|
||||||
|
|
||||||
@app.route("/supersecretpath")
|
@app.route("/supersecretpath")
|
||||||
def supersecretpath():
|
def supersecretpath():
|
||||||
ascii_art = ""
|
ascii_art = ""
|
||||||
@ -806,8 +814,6 @@ def catch_all(path: str):
|
|||||||
if filename:
|
if filename:
|
||||||
return send_file(filename)
|
return send_file(filename)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return render_template("404.html"), 404
|
return render_template("404.html"), 404
|
||||||
|
|
||||||
|
|
||||||
@ -845,7 +851,6 @@ def hnsdoh_acme():
|
|||||||
return jsonify({"status": "success"})
|
return jsonify({"status": "success"})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# endregion
|
# endregion
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user