Using folium with flask

A very common use case is to use folium with in a flask app. The trick is to return folium’s HTML representation. Here is an example on how to do that:


    Required packages:
    - flask
    - folium


    Start the flask server by running:

        $ python

    And then head to in your browser to see the map displayed


from flask import Flask

import folium

app = Flask(__name__)

def index():
    start_coords = (46.9540700, 142.7360300)
    folium_map = folium.Map(location=start_coords, zoom_start=14)
    return folium_map._repr_html_()

if __name__ == '__main__':