Creating the Flask Project
00:00
With your environment set up, let’s create the actual Flask project. First, import the Flask class. This line imports the necessary class to create your Flask application.
00:12
Then, you need to create a Flask app instance. This creates an object named app that represents your web application. The __name__ variable with double underscores before and after it is also called dunder name.
00:25
Dunder is short for double underscores. __name__ is a special variable that holds the name of the current module. It is crucial to determine the root path of the application.
00:36
This allows Flask to locate static files, templates, and other resources. Finally, you need to define a route for your homepage. The app.route() decorator tells Flask to call the index() function when the user visits the root URL.
00:52
The index() function simply returns the string “Hello, World!” and this will be the content displayed on the homepage.
00:59
Now let’s do this in our IDE. Create a new file and call it main.py.
01:13
Here we have imported the Flask class, initialized the Flask object, and created a route for our root URL.
Become a Member to join the conversation.
