Flask — QuickStart

A Pythonic Web Application

Gal Hever
2 min readDec 14, 2020

What is Flask?

Flask is a framework that was written in python and is used for building web applications. Flask is really easy to get started because of the pythonic that it is written so if you are a beginner no worries;)

Let’s dirt our hands a bit!

So just to warm up, let’s create ‘Hello World’ page!

Before we start, we need to install Flask, you can use the next code in the terminal or if you use PyCharm so you can also click on File->settings->Project Interpeter->Left click on the + icon and download the package.

pip install flask

Now, open a new python file and import from flask framework the Flask class:

from flask import Flask

Now, we will create a Flask instance that will receive __name__ variable that gets as value the string "__main__" when the code been executed:

app = Flask(__name__)

Now we will create the homepage adding to the URL the ‘/’:

@app.route("/")
def homepage():
return "Hello World!"
if __name__ == "__main__":
app.run()

We could have added the route ‘/hellopage/’ instead of ‘/’ and our URL would have looked like that: localhost:5000/hellopage/.

Run your app

Now run the app that you have created. In the terminal you will see the URL, and when you will open it on browser you will see:

Hello World!

End Notes

Good on ya! You managed to create your first Flask web page! If you want to continue and learn more about Flask, I’ll publish another tutorial soon and we will work with more complicated methods. See you soon!

--

--