I'm trying to determine wether a certain form submission was posted from an external device. For this I create a custom id if the user interacts with this app.route. Later I would like to use an if statement to check if the guest_id exists in the session (and therefore conclude that the submission was indeed made not from the main device). But when I try to post it from my phone, I keep getting KeyError from guest_id.
@app.route('/use_device.html', methods=['POST', 'GET'])
def use_device():
if request.method == 'POST':
session['guest_id'] = 'custom'
print(session['guest_id'])
return render_template('use_device.html')
@app.route('/submit', methods=['POST', 'GET'])
def submit():
if 'guest_id' in session:
print(session['guest_id'])
I tried to ask around, and look for help online, but all I got was to check if the names, and routes are set up correctly. I believe they are and I don't really see the discrepancy here. Looking for help :c