I'm developing a python flask web application that takes user input for which cities to plan a route for, geocodes the input cities by querying a third party API, and uses that result to query another API to determine the optimal route and driving directions. I have two routes that use the output of the optimal route query to generate an itinerary table and a folium map. Currently the API calls happen twice, once within the itinerary table route and once in the folium app route and I was aiming fix that by running it once and passing the results to each in turn. The initial steps are fine as I'm able to store the geocoded city results in a session value and access it no problem. However the optimal route directions are too large for containing in a session cookie, additionally I'm getting a type error with the destination order that I'm saving to a session value as well. The app is deployed on google cloud. Any advice on what is the best/simplest method to make the list of latitude/longitude coordinates for the optimal route driving directions available to both the map and the itinerary? I've seen some posts about KV session (https://pythonhosted.org/Flask-KVSession/) and talk about using a server side database. Not sure if those are my only options or if there is anything else that might be easier to setup. Skeleton code of my app @app.route('/', methods=['GET', 'POST']) def homePage(): return render_template('index.html') @app.route('/uploadFile', methods=['GET', 'POST']) def uploadFile(): # takes user uploaded text file and saves as session['uploaded_data_file'] return redirect(url_for('geocodeUpload')) @app.route('/checkUpload', methods=['GET', 'POST']) def geocodeUpload(): # gets uploaded file of cities and sends to geocoding API and then saves to session. session['geocodeTable'] = geocodeTable return render_template("confirm_upload.html", geocodeTable=geocodeTable) # user clicks on generate itinerary in html page @app.route('/queryAPI', methods=['GET','POST']) def queryAPI(): # this is the section I'm building to handle the optimal route query return redirect(url_for('showItinerary')) @app.route('/itinerary', methods=['GET','POST']) def showItinerary(): # currently gets geocoded cities from session and queries API by itself return render_template('itinerary.html', itinerary=itinerary) @app.route('/map') def displayMap(): # called from iframe within itinerary.html. gets geocoded cities and queries API to make map m.save(map_file) return open(map_file).read() In case relevant, everything is wrapped in def create_app(test_config=None): # create and configure the app app = Flask(__name__, instance_relative_config=True) return app From (https://flask.palletsprojects.com/en/stable/patterns/appfactories/) Continue reading...