Creating a Raspberry Pi Web Server Using Python
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 http://www.learn2crack.com/2013/08/setup-vnc-server-in-raspberry-pi-linux.html and to set up SD card for your Raspberry Pi use this tutorial http://www.learn2crack.com/2013/08/setup-sd-card-for-raspberry-pi.html.
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 server_pi.py and paste the following code into it and run using the command python server_pi.py in terminal.
from flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "Hello World!" if __name__ == "__main__": app.run(host='0.0.0.0', 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 10.42.0.41) in your browser address bar.
5.If you get the message HELLO WORLD! displayed it means that your web server is working.
Any questions comment here.
Latest posts by srinivasan (see all)
- Adsense EFT is Now Available for all Publishers in India - March 5, 2014
- How to Download Mega.co.nz Files Using Internet download Manager or MegaDownload Manager - February 26, 2014
- Install Android 4.4 Kitkat on your PC using Virtual Box - February 21, 2014