烧瓶不显示图像

时间:2020-05-31 13:30:18

标签: python html flask

因此,我想使用Flask在HTML页面上显示图表,但是当我运行网站时,则看不到该图像。我知道这里有几个类似的问题,但我只是坚持。

这是我的Python代码:

from flask import Flask, render_template

app = Flask(__name__)

@app.route("/")
def hello():
    return render_template('test.html')

if __name__ == "__main__":
   app.run(debug=True)

这是我的HTML代码:

<!DOCTYPE html>
<html>

  <head>
    <title>Test</title>
  </head>

  <body>
    <h1>Diagramm</h1>
    <img src="{{url_for('static', filename='test.jpg')}}" alt="Here should be a picture"/>
  </body>

</html>

这是我的文件路径:

/home/pi/flask
         /static
                /test.jpg
         /templates
                /test.html
         website.py #This is the Programm

0 个答案:

没有答案
相关问题