Python Programing Lab EXERCISE NO : 12(a) EXERCISE - 12(b) EXERCISE - 12(C)

EXERCISE NO : 12(a)

Description:


pip is a package management system used to install and manage software packages written in Python. Many packages can be found in the Python Package Index(PyPI). Python 2.7.9 and later (on the python2 series), and Python 3.4 and later include pip (pip3 for Python 3) by default.
Pip is a recursive acronym that can stand for either "Pip Installs Packages" or "Pip Installs Python". One major advantage of pip is the ease of its command-line interface, which makes installing Python software packages as easy as issuing one command:
 Write a procedure to Install packages requests, flask and explore them using pip.

pip install package-name

EXERCISE - 12(b) 

Description:

The different steps involved in making request to the server is summarized below:
  1. Make Request:
    Request is made by importing the requests module.
    Example:
    import requests
  2. Get the webpage using get():
    r = requests.get('url')(r stands for Response object) HTTP POST request can be made using post()
    r = requests.post('url', data = {'key':'value'})
  3. Response Content:
    Content of the server's response can be read using text property.
    Example:
    import requests
    r = requests.get('http://www.google.com') r.text
  4. Response status code:
    It can be retrieved using r.status_code. Where, r is response object.
  5. Response headers:
    Servers response headers can be viewed using r.headers.
  6. Cookies:
    These can be obtained using r.cookies['cookie name']


    EXERCISE - 12(C)

    Description:

    It defines classes which implement the client side of the HTTP and HTTPS protocols. The different steps involving in establishing connection to the server is:
    • Get HTTP Connection instance using httplib.HTTPConnection().
    • Request a web page using request() belonging to Connection instance.
    • Once the request is sent to the server, response is retrieved from the server using
      getresponse() returning a HTTPResponse instance.
    • 4  Read the response using response instance read().
    • Read status of response.
    • 6  Close the connection to the server.

No comments

File Uploading in PHP

  File Uploading in PHP PHP allow you to upload any type of a file i.e. image, binary or text files.etc..,PHP has one in built global variab...