how can I load svg file into my python flask page? [duplicate] how can I load svg file into my python flask page? [duplicate] flask flask

how can I load svg file into my python flask page? [duplicate]


this did the trick:

from flask import Markup@app.route('/map_test/')def test():   svg = open('file.svg').read   return render_template('test.html', svg=Markup(svg))


from flask import Flask, render_templateapp = Flask(__name__)@app.route('/')def hello_world():   img = './static/download.svg'   return render_template('index.html', img=img)if __name__ == '__main__':   app.run()

index.html

<!DOCTYPE html><html lang="en"><body><img src="{{ img }}"></body></html>

put your svg file in dir called static