Using Flask to embed a local HTML page [duplicate]

喜欢而已 提交于 2019-12-03 08:22:28

You have your route defined incorrectly. As you had it written, you defined the route for http://yourserver/http://127.0.0.1:4995/maps/map when instead what I think you wanted was http://yourserver/maps/map.html. To achieve this, you will want to use the following

@app.route('/maps/map.html')
def show_map():
    return flask.send_file('/maps/map.html')

Flask will automatically prepend your server's address (http://127.0.0.1:4995) to the beginning of any route that you define.

Also, in the template for your HTML, I would use url_for to get the URL for the map to avoid changes in your routes requiring changes to your templates.

<iframe src="{{ url_for('show_map') }}"></iframe>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!