Flask- Hello World


In this tutorial, we will create a basic hello world app. Before we do that, we need to install virtualenv. This step is optional and you can skip it, but it is recommended.  The advantage is that virtualenv allows us to have multiple Python environments, and hence install different versions of libraries. See here on how to install VirtualEnv.

Windows Users: Seriously consider installing Anaconda Python.

1. Create a virtual environment.

This step maybe different on your Python install. On most versions, the command is:

See this tutorial for more.

This step will create a directory called myblog2, with a local version of Python,

2. Cd to myblog2. To activate the virtual environment:

You should see something like:

(myblog2) C:stgithubmyblog2>

The key thing is the part in bold. If you don’t see that, it means virtualenv hasn’t activated.

3. Install Flask

You should see pip installing Flask and any required dependencies.

Hello World

In this directory, create a file called blog.py (or anything else you want to call it), and add the following code:

We import Flask and create an instance. We then define a route “/” -which means the default web address, which will be localhost for us.

On the command prompt, run the script: python blog.py

Then open a web browser and go to

You should see the Hello World message.

And that is your first Python Flask app.


2 thoughts on “Flask- Hello World”

Leave a Reply

Your email address will not be published. Required fields are marked *