FUNDAMENTALS OF HTTP REQUEST IN PYTHON

An HTTP request is made by a client, to a named host, which is located on a server. The aim of the request is to access a resource on the server.

To make the request, the client uses components of a URL (Uniform Resource Locator), which includes the information needed to access the resource.

In python, a standard module is used for this task, urllib which involves manual addition of query strings to your url or to form-code your POST. It is actually a boring stuff and is highly prone to error.

Request has come to salvage this situation. Requests is an open source python library which helps to do this task seamlessly and with a little lines of code. The components of URL which involves PUT, GET, POST, DELETE can be done by just creating the object of the request.

Before you start, you have to pip install requests on your engine using the code.
'''
pip install requests

'''
Then, you import it into your python file using the command import

'''
import requests

'''

Then, you can now call any of the component by creating an object of it. Perfect examples of this is this:
'''
r = requests.put('https://httpbin.org/put', data {'key':'value'})
r =requests.delete('https://httpbin.org/delete')
r = requests.head('https://httpbin.org/get')
r = requests.options('https://httpbin.org/get')

'''

To practice, you can copy the code above.

That is all to get started with request.

Passing Parameters in URL will be discussed in the future article.

Thank you for taking your time through this piece.

Please comment and share

Please refer to Requests Doc for more information about request.

19