I have a small project about streaming movie(720p). in Python Flask, Can anyone give me a example how to stream a video from a local disk in python flask. so its played on the homepage. What depedencies are avaible for this.
Thank you
On
You might have come across manual solutions but Flask already has a helper function for you to stream media files with ease.
You need to use the send_from_directory method from helpers.py https://flask.palletsprojects.com/en/1.1.x/api/#flask.send_from_directory
you can use it like this:
@app.route("/movies", methods=["GET"])
def get_movie():
return send_from_directory(
app.config["UPLOAD_FOLDER"],
"your_movie.png",
conditional=True,
)
There is an excellent article on this subject, Video Streaming with Flask, written by Miguel Grinberg on his blog.
As he says and explains it very well, streaming with Flask is as simple as that:
app.py
index.html:
All the details are in the article.
From there...
In your case the work is considerably simplified :
Source : Miguel's Blog