python - Flask-webage background image doesnt work -
below simple html code
index.html
<html> <head> <title>webpage</title> <link href="http://getbootstrap.com/dist/css/bootstrap.min.css" rel="stylesheet" > <link href="http://getbootstrap.com/examples/jumbotron-narrow/jumbotron-narrow.css" rel="sylesheet"> </head> <body> <style type=text/css> background-image: url("static/images/back.png"); </style> <p>does image work? </p> </body> </html>
this flask code:
app.py
from flask import flask, render_template app = flask(__name__, static_url_path="static", static_folder="static") @app.route("/") def main(): return render_template("index.html") if __name__ == '__main__': app.run()
i error when tried inspect page: get http://127.0.0.1:5000/static/images/back.png-404(not found)
i read through couple of other forums, couldn't find solution problem. images in following folder:
flaskapp templates static images back.png
when open index.html file, works perfect, when try run python file run server, background image isnt seen.
not sure how proceed.
put static folder next flask app
/flaskapp -app.py static/ images/ -back.png templates/ -index.html ....
you should not have tell flask it... know
app.py
from flask import flask, render_template app = flask(__name__) @app.route("/") def main(): return render_template("index.html") if __name__ == '__main__': app.run()
Comments
Post a Comment