I have a program that generates an image. Now I want to use Flask to make this snapshot available to other users, but I cannot display this image with the following code:
#!/usr/bin/python2 #coding: utf-8 from flask import * app = Flask(__name__) #app.run(host='0.0.0.0') @app.route('/') def index(): return render_template('hello.html') if __name__ == '__main__': app.run(debug=True,host='0.0.0.0')
My hello.html template:
<!doctype html> <title>Hello from Flask</title> <h1>Hello World!</h1> <img src="./weather-plot.png">
When I run this program and visit the page, I see the following:
192.168.0.61 - - [10/Jul/2013 10:22:09] "GET / HTTP/1.1" 200 - 192.168.0.61 - - [10/Jul/2013 10:22:09] "GET /weather-plot.png HTTP/1.1" 200 -
And in my browser I see the name, but not the image. What's wrong?
By the way, is there a better way to display a picture without any others? Maybe I do not need to use a template?
python html flask
Shan-x
source share