Using Raspberry pi a lot of thinks can be done. Now in this post i will be showing you how turn your raspberry pi in to a web server.
For this we will be using a python web framework called Flask. In order to setup VNC and control Raspberry Pi from your PC use this tutorial and to set up SD card for your Raspberry Pi use this tutorial


1.To install flask you need to install pip. You can install it using the following command in your raspberry pi terminal.

sudo apt-get install python-pip

2.To install flask use the following command.

sudo pip install flask

3.Now you need to create a file named and paste the following code into it and run using the command python in terminal.

from flask import Flask
app = Flask(__name__)
def hello():
  return "Hello World!"
if __name__ == "__main__":'', port=80, debug=True)

Note:please make sure that the code is properly aligned.

4.Now to test the server you need to type your raspberrypi ip address(mine is in your browser address bar.

5.If you get the message HELLO WORLD! displayed it means that your web server is working.

Enjoy 🙂


[Also Read: Setup Apache Web Server with PHP, MySQL in Raspberry Pi]

Any questions comment here.



Content Creator at learn2crack
Am an active blogger who loves programming, gaming, computer and internet tricks.
  • Pingback: Creating Raspberry Pi Web Server Using Python |...()

  • Pingback: Creación de un servidor WEB en la Raspberry Pi con Python - Raspberry Pi | Python()

  • kennedynyaga

    Where does one create the file named

  • Srini Vasan

    in the raspberry pi terminal use this command nano to create the text file.then copy the code in to it.

    • kennedynyaga

      That creates the file in root. isn’t there www/

      • Yes it creates in root. No need for www

        • kennedynyaga


  • Spencer

    What do you full in for the name and main? I keep getting errors

  • Kasper Masschaele

    Will you be able to reach this web server from outside your personal network? If not, any ideas how to solve this?

    • Srini Vasan

      Sorry you can’t