Why not making a website before you even learn how to make a website?
Yes, it will be just a page with some plain text, but it is still called a website and that’s how it starts. Python is concise, so it takes only seven lines of code to build what you see in the screenshot. Let’s do it.
Insert the following lines of Python code inside an empty text file, and name the file something like hello.py.
from flask import Flask
app = Flask(__name__)
return "Hey there!"
if __name__ == '__main__':
As you can see, we are importing the Flask library in the first line. If you don’t have that library installed, you will get an error. To install flask, simply type in pip install flask in your computer terminal/command line. Once you have made sure flask is installed, simply run the hello.py script.
Once you run the script, the website should now be up and running on your local machine, and it can be viewed by visiting localhost:5000 in your browser. That’s a good start.
Let’s move on!Next Lecture
Learn Flask development and learn to build cool apps with our premium Python course on Udemy.