--
This commit is contained in:
@@ -257,6 +257,17 @@ async def default_response(request: Request, full_path: str) -> Response:
|
|||||||
else:
|
else:
|
||||||
lightweight_mode = request.cookies.get("lightweight_mode", "") == "true"
|
lightweight_mode = request.cookies.get("lightweight_mode", "") == "true"
|
||||||
|
|
||||||
|
donotcount_query = request.query_params.get("donotcount", "").lower()
|
||||||
|
donotcount_header = request.headers.get("donotcount", "").lower()
|
||||||
|
donotcount_signal = donotcount_query or donotcount_header
|
||||||
|
|
||||||
|
if donotcount_signal in ["1", "y", "yes", "true"]:
|
||||||
|
donotcount_mode = True
|
||||||
|
elif donotcount_signal in ["0", "n", "no", "false"]:
|
||||||
|
donotcount_mode = False
|
||||||
|
else:
|
||||||
|
donotcount_mode = request.cookies.get("donotcount_mode", "") == "true"
|
||||||
|
|
||||||
if full_path in ["", "/"]:
|
if full_path in ["", "/"]:
|
||||||
template_candidates = ["index.html"]
|
template_candidates = ["index.html"]
|
||||||
elif full_path.endswith(".html"):
|
elif full_path.endswith(".html"):
|
||||||
@@ -284,7 +295,12 @@ async def default_response(request: Request, full_path: str) -> Response:
|
|||||||
if request.cookies.get("lightweight_mode", "") == "true":
|
if request.cookies.get("lightweight_mode", "") == "true":
|
||||||
response.set_cookie("lightweight_mode", "false", samesite="lax")
|
response.set_cookie("lightweight_mode", "false", samesite="lax")
|
||||||
|
|
||||||
accesscounter.increase()
|
if donotcount_mode:
|
||||||
|
accesscounter.increase()
|
||||||
|
response.set_cookie("donotcount_mode", "true", samesite="lax")
|
||||||
|
elif request.cookies.get("donotcount_mode", "") == "true":
|
||||||
|
response.set_cookie("donotcount_mode", "false", samesite="lax")
|
||||||
|
|
||||||
return response
|
return response
|
||||||
except TemplateNotFound:
|
except TemplateNotFound:
|
||||||
continue
|
continue
|
||||||
@@ -333,7 +349,12 @@ async def default_response(request: Request, full_path: str) -> Response:
|
|||||||
elif request.cookies.get("lightweight_mode", "") == "true":
|
elif request.cookies.get("lightweight_mode", "") == "true":
|
||||||
response.set_cookie("lightweight_mode", "false", samesite="lax")
|
response.set_cookie("lightweight_mode", "false", samesite="lax")
|
||||||
|
|
||||||
accesscounter.increase()
|
if donotcount_mode:
|
||||||
|
accesscounter.increase()
|
||||||
|
response.set_cookie("donotcount_mode", "true", samesite="lax")
|
||||||
|
elif request.cookies.get("donotcount_mode", "") == "true":
|
||||||
|
response.set_cookie("donotcount_mode", "false", samesite="lax")
|
||||||
|
|
||||||
return response
|
return response
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user