-1

I am trying to use Flask for the first time. Currently, I am trying to show a local video on a website. I created an HTML file that displays a video:

<source src="../video_1.mp4" type="video/mp4">

However, the video doesn't display- when the web page is open there is a black box. Therefore, I changed the source line in my HTML to the following line:

<a href="https://drive.google.com/file/d/1vUC-eLApqLPSW3qIq4kNsiOdIjnm22o7/view?usp=sharing"></a>

When running the HTML code the video worked. But, when I am running the code from a python file the video doesn't work, and no error appears

from flask import Flask,redirect,url_for,render_template
app = Flask(__name__)
@app.route("/")
def home():
    return render_template("index.html")
 if __name__ == "__main__":
    app.run()[enter image description here][1]

Please help me run the HTML file from my python file in a way that the video will display [1]: https://i.stack.imgur.com/aBoNm.png

yael
  • 21
  • 1
  • 5

1 Answers1

0

In your index.html file:

<video width="320" height="240" controls>
    <source src="{{url_for('static', filename='myvideo.mp4')}}" type="video/mp4">
</video>

Also make sure to have a folder named static in your project and put your video inside it. Like this

ale-mt
  • 46
  • 3