When I press play on any song in the media listing it has to get sent a send_file... however whilst the send_file is in progress, the whole website freezes meaning that if this send_file happens and someone goes to the main page of the website, they'll be waiting for as long as the send_file takes.
Here is my code:
@app.route('/getMedia/')
def getMedia():
file = request.args.get('filename')
def getReqFile():
with open(f'./media/{file}', mode="rb") as file_like:
yield from file_like
try:
# send_file(f'./media/{file}', conditional=True, as_attachment=True)
return Response(getReqFile())
except FileNotFoundError:
return 'The media you tried to view doesn\'t exist.'
I'm not sure how to word this better, so I'm sorry if it doesn't make sense.