How to build a frontend for my youtube video downloader program?
Question:
I want to build a basic frontend for the below program, so that when users enter the app they will get the same output as in a python interpreter.
here is the python code
from pytube import YouTube
def Download(link):
youtubeObject = YouTube(link)
youtubeObject = youtubeObject.streams.get_highest_resolution()
try:
youtubeObject.download()
except:
print("There has been an error in downloading your youtube video")
print("This download has completed! Yahooooo!")
link = input("Put your youtube link here!! URL: ")
Download(link)
I am expecting to build a small app where users can enter their video link and download the video. I just want to learn how to integrate it with a good looking user interface.
Answers:
- A web browser cannot interpret python, so your python code will live on an another computer.
- That another computer is a server, and to communicate with the server, you’ll need an API route. e.g
(/process)
- The frontend will hit the API with the link as a parameter. (let’s say)
(/process?link=<youtube-link>)
- The logic for handling that API will be written on the server. You can choose any language for that. Since you’re familiar with Python already, use Flask or Fast API.
- Once you host your server code you’re ready for communicating with the front-end with simple Fetch API.
References:
I want to build a basic frontend for the below program, so that when users enter the app they will get the same output as in a python interpreter.
here is the python code
from pytube import YouTube
def Download(link):
youtubeObject = YouTube(link)
youtubeObject = youtubeObject.streams.get_highest_resolution()
try:
youtubeObject.download()
except:
print("There has been an error in downloading your youtube video")
print("This download has completed! Yahooooo!")
link = input("Put your youtube link here!! URL: ")
Download(link)
I am expecting to build a small app where users can enter their video link and download the video. I just want to learn how to integrate it with a good looking user interface.
- A web browser cannot interpret python, so your python code will live on an another computer.
- That another computer is a server, and to communicate with the server, you’ll need an API route. e.g
(/process)
- The frontend will hit the API with the link as a parameter. (let’s say)
(/process?link=<youtube-link>)
- The logic for handling that API will be written on the server. You can choose any language for that. Since you’re familiar with Python already, use Flask or Fast API.
- Once you host your server code you’re ready for communicating with the front-end with simple Fetch API.