-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
ocefpaf
merged 7 commits into
python-visualization:master
from
GiantRobato:add-flask-examples
May 26, 2019
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a833f2f
added simple example using flask
GiantRobato 1036708
fixed ci issues
GiantRobato 5fa3336
fixed newline
GiantRobato 20f1a65
reordered tutorial docs
GiantRobato 12d1838
added example usage
GiantRobato f6dfe46
reference the file
ocefpaf a88d68f
fix lints
ocefpaf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,5 +33,6 @@ Contents | |
|
||
installing | ||
quickstart.ipynb | ||
flask | ||
modules | ||
plugins |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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('/') | ||
GiantRobato marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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__': | ||
GiantRobato marked this conversation as resolved.
Show resolved
Hide resolved
|
||
app.run(debug=True) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.