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

2. Make Application Directory for Flask Application

3. Copy and paste the content below into app.py

Note here the host=’0.0.0.0′ 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 http://0.0.0.0:5000/
* Restarting with reloader

4. Head to 127.0.0.1:5000 in your Raspberry Pi Web Browser

You should now be able to navigate to 127.0.0.1:5000 (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.

 

CanaKit Raspberry Pi 3 Complete Starter Kit – 32 GB Edition (Personal Computers)


List Price: $74.99 USD
New From: $65.00 USD In Stock
Used from: $62.00 USD In Stock

Buffalo iBuffalo Classic USB Gamepad for PC BSGP801GY (Personal Computers)


List Price: $16.33 USD
New From: $10.35 USD In Stock
Used from: $15.00 USD In Stock

Official Raspberry Pi 3 Case – Black/Grey (Accessory)


List Price: $7.71 USD
New From: $6.79 USD In Stock
Used from: $7.40 USD In Stock

SanDisk Ultra 32GB microSDHC UHS-I Card with Adapter, Grey/Red, Standard Packaging (SDSQUNC-032G-GN6MA) (Personal Computers)


List Price: $13.95 USD
New From: $13.95 USD In Stock
Used from: $10.00 USD In Stock

Leave a Reply

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