I want to insert follium map into the jinja template.
run.py
from flask import Flask, render_template
app = Flask(__name__)
@app.rou
Maybe it can be the solution. First we save a Folium map as an html file on templates folder. Then we create a Flask route to render another html file. On that html file, we create an iframe element that call our map.
Here is the file structure:
proectApp
├── app.py
└── templates
├── index.html
└── map.html
Folium map file (map.html) will be created automatically from my app.py. On app.py I'll create 2 main route: the first one is the home route which will render index.html & create map.html. Then the other is to render folium map (map.html). Here are the codes:
app.py
from flask import Flask, render_template
import folium
app = Flask(__name__)
@app.route('/')
def index():
start_coords = (-6.1753924, 106.8271528)
folium_map = folium.Map(
location=start_coords,
zoom_start=17
)
folium_map.save('templates/map.html')
return render_template('index.html')
@app.route('/map')
def map():
return render_template('7_map.html')
if __name__ == '__main__':
app.run(debug=True)
index.html
Folium Map
Render Folium on Flask