Skip to main content

Raspberry Pi making HTTP requests using Python




Raspberry Pi making HTTP requests using Python

HTTP GET and POST requests can be used to communicate with web servers ,api etc. Using this method you can develop some cool apps with your Raspberry Pi. In this tutorial we are going to see how to make HTTP GET and POST requests with your Raspberry Pi.

Making HTTP GET requests

In Raspberry Pi the HTTP GET requests can be made using the package urllib. The code is very simple. By using the method urllib.urlopen() you can get the contents of the page. In this example I am making HTTP GET request to the url “http://api.learn2crack.com/rpi/rpi_get.php”. It will print the output as “Hello Raspberry Pi”.

Example

Making HTTP POST requests

Http POST requests can be made using the package urllib and urllib2. The post parameters should be in the format of { ‘data’:’data’ }. The post request can be made using the method urllib2.Request(). By using the method urllib2.urlopen() you can get the contents of the page. In this example I am making HTTP POST request to the url “http://api.learn2crack.com/rpi/rpi_post.php”. It will print the output as “State is : Active”.

Example

Steps to execute the code

1. Open the Raspberry Pi terminal.
2. Then type nano program.py
3. Now type the python program and save it.
4. Execute using the command python program.py

Comments

Popular posts from this blog

Samsung Galaxy Grand Neo I9060 Cell Phone Screen Repair Light Problem Solution Jumper Ways Smartphone Repairing

Samsung Galaxy Grand Neo I9060 Cell Phone Screen Repair Light Problem Solution Jumper Ways Smartphone Repairing This post is all about Samsung Galaxy Grand Neo I9060 fix phone screen problem solution. If mobile phone scree display is not working good or the screen light is not working. Samsung Galaxy Grand Neo I9060 cracked screen repair is only possible with phone screen replacement. But if the screen is not broken then replace phone screen is not required. Smartphone Repairing If Samsung Galaxy Grand Neo I9060 screen is blinking or dim light having blank scree. In all these case we have to disassemble the smart phone and check screen jack if there is any rust carbon or damages of screen jack pins.Samsung Galaxy Grand Neo I9060 phone repair tutorials are given in a few more posts so you can search other repairing problem solutions here. If screen jack have no any fault then the above mobile screen repair diagram will help you to find out tracks that are used in screen functi...

Samsung Galaxy S6 Edge Power On Off Key Button Switch Jumper Ways Smartphone Repairing

Samsung Galaxy S6 Edge Power On Off Key Button Switch Jumper Ways Smartphone Repairing Samsung Galaxy S6 Edge charging ok, flash ok, but not powering phone, this mean power button cut/line problem.So now follow simple power button jumper ways. Smartphone Repairing If you are facing an energy problem in Samsung Galaxy S6 Edge diagrams in this article can help. Continue with the following troubleshooting solutions and establish bridges necessary for the points that have been damaged. Samsung Galaxy S6 Edge Dead does not start Solution Samsung Galaxy S6 Edge keys Power Jumper Samsung Galaxy S6 Edge On Off Button Ways Samsung Galaxy S6 Edge power button point Trick damaged bridge. Trace point of damage to the meter or check off switch with a new one. We can check problem button to connect the phone to the charger with mobile entertainment indicator appears on the screen and pressing the power button, then this is a power button problem. See diagram and apply jumpers as diagram. Smar...

How to Capture WPA Passwords with Fluxion

How to Capture WPA Passwords with Fluxion Install Fluxion To get Fluxion running on our Kali Linux system, clone the git repository with: git clone =>https://github.com/wi-fi-analyzer/fluxion Note: The developer of Fluxion shut down the product recently, but you can get an older version of it using the command above instead (not the URL you see in the image below). Then, let's check for missing dependencies by navigating to the folder and starting it up for the first time. cd fluxion sudo ./fluxion You'll likely see the following, where some dependencies will be needed. Run the installer to fetch dependencies and set your board to green with: sudo ./Installer.sh A window will open to handle installing the missing packages. Be patient and let it finish installing dependencies. After all the dependencies are met, our board is green and we can proceed to the attack interface. Run the Fluxion command again with sudo ./fluxion ...