I have a web application focused around playing videos. It uses a flask api to serve the metadata. I want to be able to pass a local filepath for a video to the client and allow the client to play that video. Since you can't just load a local file, how can I serve the file to the browser? I know there is simplehttpserver but I have files all over the place.
How can I set it up so that I can use the vlc plugin like in this post Open video stream on VLC Player through the browser?
UPDATE
This is not a duplicate. I am asking how can I serve a file from a client-supplied filepath. This can be any location, not just one directory of static css/html/js files I want served. Since the client is getting the filepath from the server, I can validate that file is allowed to be served.
UPDATE 2
Still do not believe this is a duplicate as it is for consumption by a specific plugin, vlc web plugin. I tried to use send_from_directory
but it did not work. Hopefully this makes it clearer. If send_from_directory` is the right thing to use though, what is my error here?
On python my endpoint is as follows (using flask-restful):
from flask import Blueprint, send_from_directory
from flask_restful import Api, Resource
class VideoServer(Resource):
def get(self, filepath):
path, file = os.path.split(filepath)
return send_from_directory(path, file)
base_blueprint.add_resource(VideoServer, '/video_server/<string:filepath')
On the js side:
let videourl = config.api_server + '/video_server/' + filepath
let $video = $("<object>", {type: "application/x-vlc-plugin", data: videourl});
let $param = $("<param>", {name: "movie", value: videourl});
let $embed = $("<embed>", {type: "application/x-vlc-plugin", autoplay: "yes", loop: "no", target: videourl});
$video.append($param);
$video.append($embed);
$("#mydiv").append($video);
$("#mydiv").load();