I'm building a Youtube Video Downloader using PyTube and Flask
. What I want to do is the end user receives the video file, but I never store it into the server.
Currently the code looks like this:
def download_video():
if request.method == "POST":
url = YouTube(session['link']) # Getting user input
itag = request.form.get("itag") # Getting user input
video = url.streams.get_by_itag(itag)
file = video.download(path) # Downloading the video into a folder
return send_file(file, as_attachment=True)
return redirect(url_for("home"))
The code works fine, the only drawback is that it is being store into the server, which later on can become an issue.
I already tried to download it to /dev/null/
, which locally seems to work, but when deployed to Heroku, it gives me an Internal Server Error
.