Итак, вот мой код:
Код: Выделить всё
from flask import render_template
import folium
import osmnx as ox
import networkx as nx
@views.route('/', methods=['GET', 'POST'])
def test():
mapObj = folium.Map(location=[40.748441, -73.985664], zoom_start=15, width=1850, height=900)
ox.config(log_console=True, use_cache=True)
G_walk = ox.graph_from_place('Manhattan Island, New York City, New York, USA',
network_type='walk')
orig_node = ox.nearest_nodes(G_walk, Y=40.748441, X=-73.985664)
dest_node = ox.nearest_nodes(G_walk, Y=40.748441, X=-73.3)
route = nx.shortest_path(G_walk,
orig_node,
dest_node,
weight='length')
route = ox.plot_route_folium(G_walk, route, width=1850, height=910).add_to(mapObj)
mapObj.get_root().render()
header = mapObj.get_root().header.render()
body_html = mapObj.get_root().html.render()
script = mapObj.get_root().script.render()
return render_template('home.html', user=current_user,
header=header, body_html=body_html, script=script)
Подробнее здесь: https://stackoverflow.com/questions/782 ... -and-osmnx