How to return a mp4 file in Flask?

So far I have something that works, but it feels like there should be a better/correct way to handle that. First, the client is making a call to the API as follows:

fetch(API_URL, request)
      .then((response) => response.json())
      .then((url) => {
        url = API_VIDEO_URL;
      });

This calls for a function to generate a video, after the process is over it saves said video on disk. After the process is over the function returns jsonify({}), 200.
As you can see, I’m not doing anything with that response as I didn’t find a way to make it work in any other way, instead, I tell the client to head to API_VIDEO_URL, another function within Flask that takes the video and sends it over.

@app.route("/video")
@cross_origin()
def api_video():
    def generate():
        with open(VIDEO_PATH, "rb") as frames:
            data = frames.read(1024)
            while data:
                yield data
                data = frames.read(1024)

    return Response(generate(), mimetype="video/mp4")

This gets the video generated by the original call and serves it to the client.(VIDEO_PATHis the path to the video). I was not able to make this work within the same function.

Is there a better way to achieve this?