Skip to content

added simple example using flask #1140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/flask.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
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 d that:


.. literalinclude:: ../examples/flask_example.py
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ Contents

installing
quickstart.ipynb
flask
modules
plugins
32 changes: 32 additions & 0 deletions examples/flask_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
""" flask_example.py
Required packages:
- flask
- folium
Usage:
Start the flask server by running:
$ python flask_example.py
And then head to http://127.0.0.1:5000/ in your browser to see the map displayed
"""

from flask import Flask

import folium

app = Flask(__name__)


@app.route('/')
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__':
app.run(debug=True)