Flask Version:
>>> flask.__version__
'0.12.2'
I do not want to update the expiration date for a specific URL.
I am currently using the following method to set session expiration time:
session.permanent = true
app.permanent_session_lifetime = timedelta(minutes=int(10))
I have a status page that automatically refreshes every minute using the ajax method to get only data.
I do not want to reset the session expiration time in this case.
Is there any way to do this?
Edit:
My code is:
from datetime import timedelta
from flask import Flask
from flask import session
APP = Flask(__name__, static_url_path='', static_folder='templates')
def create_user_session(user_accountid, auth_token):
session['token'] = auth_token
session['user_accountid'] = user_accountid
def update_session():
session.permanent = True
APP.permanent_session_lifetime = timedelta(minutes=10)
session.modified = True
@APP.route('/batch_status', methods=['GET'])
def view_status():
create_user_session(1, "****")
update_session()
return "Session Change"
@APP.route('/batch_status_json', methods=['GET'])
def retrieve_status():
return "Session No Change"
if __name__ == '__main__':
APP.secret_key = "My Precious Key"
APP.run(host='0.0.0.0', debug=True, port=8000)
I do not want to change the session expiration time on a call batch_status_json
, but it automatically changes on a call.
Edit2:
monitor_controller.py:
from datetime import timedelta
from flask import Flask
from flask import session
from status import RETRIEVE_STATUS
APP = Flask(__name__, static_url_path='', static_folder='templates')
APP.register_blueprint(RETRIEVE_STATUS)
def create_user_session(user_accountid, auth_token):
session['token'] = auth_token
session['user_accountid'] = user_accountid
def update_session():
session.permanent = True
APP.permanent_session_lifetime = timedelta(minutes=10)
session.modified = True
@APP.route('/batch_status', methods=['GET'])
def view_status():
create_user_session(1, "****")
update_session()
return "Session Change"
if __name__ == '__main__':
APP.secret_key = "My Precious Key"
APP.run(host='0.0.0.0', debug=True, port=8000)
status.py:
from flask import Blueprint
RETRIEVE_STATUS = Blueprint('retrieve_status', __name__)
@RETRIEVE_STATUS.route('/batch_status_json', methods=['GET'])
def retrieve_status():
return "Session No Change"
source
share