Question

In Pycharm, Write a client to consume a REST web service of you choice using Python....

In Pycharm, Write a client to consume a REST web service of you choice using Python. Your information should produce useful information. I.e. a dump of cryptic data is not the desired product.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

we need to write a client to consume a REST web service

Python code to perform one of the REST calls, in our case GET:

So here the code sends a GET request to find the lattitude, longitude and formatted address of a given location by sending a GET request to Google Maps API.

Python code:

# importing the requests library

import requests

# api-endpoint

URL = "http://maps.googleapis.com/maps/api/geocode/json"

# location given here

location = "delhi technological university"

# defining a params dict for the parameters to be sent to the API

PARAMS = {'address':location}

# sending get request and saving the response as response object

r = requests.get(url = URL, params = PARAMS)

# extracting data in json format

data = r.json()

# extracting latitude, longitude and formatted address

# of the first matching location

latitude = data['results'][0]['geometry']['location']['lat']

longitude = data['results'][0]['geometry']['location']['lng']

formatted_address = data['results'][0]['formatted_address']

  

# printing the output

print("Latitude:%s\nLongitude:%s\nFormatted Address:%s"

%(latitude, longitude,formatted_address))

Add a comment
Know the answer?
Add Answer to:
In Pycharm, Write a client to consume a REST web service of you choice using Python....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • You publish an Azure ML experiment as a web service for use by a client application...

    You publish an Azure ML experiment as a web service for use by a client application that must generate predicted sales values for high volumes of product data asynchronously. Which endpoint should the application use to consume the web service? a. The URL of the experiment in Azure ML Studio. b. The Request-Response Service URL for the web service. c. The Batch Execution Service URL for the web service. d. The URL of an Excel workbook in a OneDrive folder.

  • What are “Web Services”? Outline the advantages and disadvantages of REST. Describe, using an appropriate table...

    What are “Web Services”? Outline the advantages and disadvantages of REST. Describe, using an appropriate table and example RESTful API, how CRUD activities are normally mapped onto REST. Describe briefly, using relevant code fragments, how to use AnjularJS to consume a RESTful web service supplying data in JSON format.

  • Using the programming language of your choice, write a client application which: Connects to a network...

    Using the programming language of your choice, write a client application which: Connects to a network service, then Asks for version information, then Receives the response, then Disconnects and Prints out the response. Detail: The program will take no input from the user. When your program is executed, it should connect to IP address 64.183.98.170 on port 3800. Upon successful connection, send the string: version\n where \n is an end of line marker. The server will respond with a string...

  • Read a form on a web page Write a CGI program (in C++) that will provide...

    Read a form on a web page Write a CGI program (in C++) that will provide 'added value'. The user is to key in a value (or select a value) in an HTML page and then run the CGI program. The program is to return a page containing useful information that is different from but related to what was keyed in. You may NOT use redirection - i.e. YOU have to provide the content of the page returned. You should...

  • (Python) Develop a crawler that collects the email addresses in the visited web pages. You can...

    (Python) Develop a crawler that collects the email addresses in the visited web pages. You can write a function emails() that takes a document (as a string) as input and returns the set of email addresses (i.e., strings) appearing in it. You should use a regular expression to find the email addresses in the document. Explain the code and how it works.

  • This is for programming using Python with the JES software. Please write the code with the...

    This is for programming using Python with the JES software. Please write the code with the proper indentation. Thanks! Problem 1: Write a function that takes 2 arguments (integer or float) and computes the sum, difference, product, and quotient of the arguments. Once you calculate the values you should print out statements telling the user what arguments we used to compute the values and what the result of each calculation (your function should produce 5 lines of output in the...

  • Using PyCharm, under lab8, under Directory exercise, create a Python file called more_loops.py. Write a function,...

    Using PyCharm, under lab8, under Directory exercise, create a Python file called more_loops.py. Write a function, nbrs_greater that accepts 2 integer lists as a parameters, and returns a list of integers that indicates how many integers in the second list are greater than each integer in the first list. For example: nbrs_greater([3, 4, 1, 2, 7], [10, 1, 4, 2, 5, 3]) returns [3, 2, 5, 4, 1] because: Number of numbers in Element of first list Numbers greater from...

  • Build an E-commerce site of your choice, selling a product or service of your choice. The...

    Build an E-commerce site of your choice, selling a product or service of your choice. The site should allow the customers to browse the available products/services, select products/services, and generate an invoice. The invoices should be stored in the system. I am making an online selling hat website. 1. Identify the business objectives, plan the e-commerce site using the SDLC. List the requirements for the web site / system

  • Using a Python environment of your choice - 1. Write a program which will, a). read...

    Using a Python environment of your choice - 1. Write a program which will, a). read an ASCII file. b). display all of its contents in upper case c). count the total number of words

  • Implement your first Networking application that uses the Client-Server model. Using Python and either TCP or...

    Implement your first Networking application that uses the Client-Server model. Using Python and either TCP or UDP Protocol, the application should do the following: 1. Client reads a line of characters (data) from its keyboard and sends data to server 2. Server receives the data and converts characters to uppercase 3. Server sends modified data to client 4. Client receives modified data and displays line on its screen

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT