forked from rDrama/rDrama
fix annoying 500 errors
parent
71807f7a27
commit
f62a9769fd
|
@ -32,9 +32,6 @@ def before_request():
|
||||||
if not request.path: request.path = '/'
|
if not request.path: request.path = '/'
|
||||||
request.full_path = request.full_path.rstrip('?').rstrip('/')
|
request.full_path = request.full_path.rstrip('?').rstrip('/')
|
||||||
if not request.full_path: request.full_path = '/'
|
if not request.full_path: request.full_path = '/'
|
||||||
if not session.get("session_id"):
|
|
||||||
session.permanent = True
|
|
||||||
session["session_id"] = secrets.token_hex(49)
|
|
||||||
|
|
||||||
@app.after_request
|
@app.after_request
|
||||||
def after_request(response):
|
def after_request(response):
|
||||||
|
|
|
@ -21,6 +21,9 @@ def calc_users(v):
|
||||||
else:
|
else:
|
||||||
ua = str(user_agents.parse(g.agent))
|
ua = str(user_agents.parse(g.agent))
|
||||||
if 'spider' not in ua.lower() and 'bot' not in ua.lower():
|
if 'spider' not in ua.lower() and 'bot' not in ua.lower():
|
||||||
|
if not session.get("session_id"):
|
||||||
|
session.permanent = True
|
||||||
|
session["session_id"] = secrets.token_hex(49)
|
||||||
loggedout[session["session_id"]] = (timestamp, ua)
|
loggedout[session["session_id"]] = (timestamp, ua)
|
||||||
|
|
||||||
loggedin = {k: v for k, v in loggedin.items() if (timestamp - v) < LOGGEDIN_ACTIVE_TIME}
|
loggedin = {k: v for k, v in loggedin.items() if (timestamp - v) < LOGGEDIN_ACTIVE_TIME}
|
||||||
|
|
Loading…
Reference in New Issue