python - Fail to show an image using Flask -


i want show image in homepage of python web application. far wrote following program:

my directories , files

mywebapp/     app/         __init__.py         views.py     templates/         home.html     static/         desert.jpg     run.py 

__init__.py

from flask import flask app = flask(__name__) app import views 

views.py

from app import app flask import render_template flask import url_for  @app.route('/') def root():     imag = url_for ('static', filename = 'desert.jpg')     tle = "hey"     return render_template('home.html', imag,tle) 

home.html

<html>     <title>{{ tle }}</title>     <body>         <img src="{{ imag }}"/>     </body> </html> 

run.py

from app import app if __name__ == "__main__":     app.run() 

and when run run.py, receive following internal server error:

enter image description here

what's wrong?

that's not correct syntax render_template function. need use keyword arguments:

return render_template('home.html', imag=imag, tle=tle) 

Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -