-1

I am making a project using html,css,bootstrap and flask, i've 3 images on the site and they don't appear when i used Flask.

MY HTML CODE.

<div class="carousel-inner">
      <div class="item active">
        <img src="C:/Users/Mahin/Desktop/Spiritus/flaskwork/Scripts/app/static/images/1.jpg" alt="Beer" style="width:100%">
      </div>

      <div class="item">
        <img src="C:/Users/Mahin/Desktop/Spiritus/flaskwork/Scripts/app/static/images/2.jpg" alt="Whiskey"  style="width:100%">
      </div>

      <div class="item">
        <img src="C:/Users/Mahin/Desktop/Spiritus/flaskwork/Scripts/app/static/images/3.jpg" alt="Vader" style="width:100%">
      </div>
    </div>

My Python code

from flask import Flask, render_template
app = Flask(__name__)

@app.route("/")
def main():
    return render_template('index.html')

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

1 Answers1

3

Since your images are already in the images folder in static, you do not need to specify the full path:

<div class="carousel-inner">
  <div class="item active">
    <img src="/static/images/1.jpg" alt="Beer" style="width:100%">
  </div>

  <div class="item">
    <img src="/static/images/2.jpg" alt="Whiskey"  style="width:100%">
  </div>

  <div class="item">
    <img src="/static/images/3.jpg" alt="Vader" style="width:100%">
  </div>
</div>
Ajax1234
  • 66,333
  • 7
  • 57
  • 95