How to Stream Video using Flask

2020-04-06 Uttkarsh Kabde

Hello programmers, today we are going to took one step ahead in our flask tutorial. Before starting coding this make sure you have basic knowledge of what is flask?,where it is used? and installing flask into your system. To know about this take a look at Here. So today we are going to create a simple webpage using flask and will try to view youtube video into this. So lets start.

To do so we need the library

flask (pip install flask)

run the command and the flask library and its components will get installed into your system. After this short installation process lets start actual coding.



from flask import Flask
app = Flask(__name__)

def homepage():
    return """
    <h1>Hello world!</h1>

    <iframe src="" width="853" height="480" ></iframe>

if __name__ == '__main__':, use_reloader=True)



 <h1>Hello world!</h1> is the heading1 tag usually used in html language. Here we are going to use this just as test case to make sure our page is loading correctly.

<iframe src="" width="853" height="480" ></iframe> This is iframe tag is An inline frame that is  used to embed another document within the current HTML document. Here we are going to embed youtube sample video into our webpage. Here we are creating a window of  width=”853” and height=”480” in which our sample video will be played.

Note that when you are using any different video from youtube just change watch?v to embed followed by video id.(Here video id is RK1K2bCg4J8)

Aslo we are using use_reloader=True here which will help us to reload and fork the process if modules or code  were changed.

After running above code the result will be same as seen below.


Here we stop for now. will be back soon with new contents. if you face any problem regarding this post, feel free to comment below. we will make sure to resolve your problem regarding this.

Thank you…

Happy coding…

About author

Card image cap
Uttkarsh Kabde

Currently I am Persuing Mtech in IT at Shri Guru Gobind Singh Institute of Engineering and Technology, Nanded!

-Web App Developer


Scroll to Top