I am trying to access request headers when a user visits a particular page. It is a cron function and according to this link. I should be able to identify if the request comes from the Service Account by checking for header X-Appengine-Cron. I've tried this and have been using request throughout my application with no problems however for this it returns the error:
local variable 'request' referenced before assignment
I have tried replicating other functions which utilise request however there is no issue there. I am using a very basic test to check it is working:
from flask import (
Blueprint, Flask, flash, g, redirect, render_template, request, url_for
)
@app.route('/cloud-datastore-export', methods = ['GET'])
def cloud_datastore_export():
test = request.headers.get('X-Appengine-Cron')
I expect test to contain X-Appengine-Cron value.