File tree Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ Using folium with flask
2
+ =======================
3
+
4
+ A very common use case is to use folium with in a flask app.
5
+ The trick is to return folium's HTML representation.
6
+ Here is an example on how to d that:
7
+
8
+
9
+ .. literalinclude :: ../examples/flask_example.py
Original file line number Diff line number Diff line change @@ -33,5 +33,6 @@ Contents
33
33
34
34
installing
35
35
quickstart.ipynb
36
+ flask
36
37
modules
37
38
plugins
Original file line number Diff line number Diff line change
1
+ """ flask_example.py
2
+
3
+ Required packages:
4
+ - flask
5
+ - folium
6
+
7
+ Usage:
8
+
9
+ Start the flask server by running:
10
+
11
+ $ python flask_example.py
12
+
13
+ And then head to http://127.0.0.1:5000/ in your browser to see the map displayed
14
+
15
+ """
16
+
17
+ from flask import Flask
18
+
19
+ import folium
20
+
21
+ app = Flask (__name__ )
22
+
23
+
24
+ @app .route ('/' )
25
+ def index ():
26
+ start_coords = (46.9540700 , 142.7360300 )
27
+ folium_map = folium .Map (location = start_coords , zoom_start = 14 )
28
+ return folium_map ._repr_html_ ()
29
+
30
+
31
+ if __name__ == '__main__' :
32
+ app .run (debug = True )
You can’t perform that action at this time.
0 commit comments