I am using Flask for a small personal project. Said project makes a call to an API that then returns a dictionary. I want to pass information from this dict to Javascript in the view. I am using the Google Maps API in the JS, specifically, so I'd like to pass it a list of tuples with the long/lat information.
Below is some example code.
from flask import Flask
from flask import render_template
app = Flask(__name__)
import foo_api
api = foo_api.API('API KEY')
@app.route('/')
def get_data():
events = api.call(get_event, arg0, arg1)
geocode = event['latitude'], event['longitude']
return render_template('get_data.html', geocode=geocode)
I know that render_template will pass these variables to the view so they can be used in HTML, but how could I pass them to javascript in the view?