Streaming MOVIE Python flask

后端 未结 2 1818
梦如初夏
梦如初夏 2021-01-16 05:15

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 t

2条回答
  •  鱼传尺愫
    2021-01-16 05:36

    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,
                )
    

提交回复
热议问题