DEV Community

Christian Lutz
Christian Lutz

Posted on

Getting started with Flask - "Hello World Wide Web!"

Creating web apps is possibly one of the coolest things you could do in your lifetime. ;)
The reasons are obvious.
You can create something meaningful, everyone can use.

With some work, you may be creating something like this:
Picture of ServerMonitor project

Follow me to get more information about the ServerMonitor in the near future.

Let's get started!


Flask is a lightweight Python web framework based on Werkzeug and Jinja2.
Lightweight means, Flask only has the most basic features to create your web application on your own.
Everything other like admin panels, for example, have to be built from scratch, unlike in Django.

For starting out in web development with Python, this makes a lot of sense.
You don't have to learn a lot of framework stuff before you can build a web app.

Create your project

Make a folder where your Flask project should be located.
You can do this in CMD on Windows.

mkdir flask_project

Then, open your created folder with:

cd flask_project


Installing flask via PIP is quite easy.
Simply type...

pip install Flask install the Flask module.

Setting up the application

After installing Flask, we have to make a Python file.
I will call it ''

This file will contain all of the basic code for Flask to run.

from flask import Flask
app = Flask(__name__)

def hello_www():
    return "Hello World Wide Web!"

Code explanation

First of all, we import our installed Flask module from Flask with:

from flask import Flask

Then, we define the variable 'app' and assign "Flask(_ name _)" to it:

app = Flask(__name__)

After that, we can create our first route with:


To make it work, we need some return value, that will be displayed on our web page.

For that, we type:

def hello_www():
    return "Hello World Wide Web!"

Last but not least, we will return a String with "Hello World Wide Web!".

Run your application

After we have created and saved our code, we want to see the result.
For that, you first need to define your Python file for Flask in this way:


If this is done, you can start your web app with:

flask run

Flask running in CMD

Go to http://localhost:5000 or, to see your result:

Your result!

You have created your first web app.

If you want to dive deeper into the Flask-World, visit

Thank you for reading!

Top comments (1)

vicradon profile image
Osinachi Chukwujama

The app didn't run on my machine. I used


instead of


and it worked.

Thanks for the article though