Well, I'm learning Flask. And now I want to show an image to browser like 127.0.0.1/test.png
.
But I can't find how to do that in document, and I've tried this but it doesn't work:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def showimage():
with open('test.png', 'rb') as f:
return f.read()
if __name__ == '__main__':
app.run()
This will only return some text. And I also want to know how to return some other type binary for download.