Python Web Server with Flask Raspberry Pi Tutorial

By following this resource and setting up a Flask web server you will learn:

  • How to install software on your Raspberry Pi
  • How to install pip and Flask to create a Python-powered web server
  • How to build a basic web app with Flask and run it as a local website on your Raspberry Pi
  • How routes are used to map URLs to web pages
  • How to use HTML to create simple web page templates
  • How to use CSS to control the appearance of HTML content
  • How to configure Flask and make your website accessible to other devices on your local network

1. Install Python 3 Flask

sudo apt-get install python3-flask

2. Make Application Directory for Flask Application

mkdir flaskapp
cd flaskapp

3. Copy and paste the content below into

from flask import Flask

app = Flask(__name__)

def index():
return 'Hello world'

if __name__ == '__main__':, host='')

Note here the host=’′ means the web app will be accessible to any device on the network.

4. Run the Application

Save the file, and return to the Terminal window. Run the command


to start up the raspberry pi flask application.

If everything has been written correctly, you should see an output similar to this:

* Running on
* Restarting with reloader

4. Head to in your Raspberry Pi Web Browser

You should now be able to navigate to (on your Raspberry Pi web browser) to see this!


Please comment below if you have any questions!

If you’d like to buy a Rasbperry Pi, check out some of the links below.


Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.