Skip to Content
Tkinter GUI Programming by Example
book

Tkinter GUI Programming by Example

by David Love
April 2018
Beginner content levelBeginner
340 pages
7h 54m
English
Packt Publishing
Content preview from Tkinter GUI Programming by Example

Sending a GET request

A GET request allows the requester (often called a client) to receive some information from a server. We can use a GET request to ask our server for some data in JSON format, which we can then use in the rest of the script.

Ensure your flask server is still running, then, open up a new Python file. Add the following content:

import requestsr = requests.get("http://127.0.0.1:5000")data = r.json()print(f"There are {data['people']} people. {data['cats']} of them have a cat, and {data['dogs']} of them have a dog")

In this example, we import the requests module and use it to send a GET request to our server using its get method.

Since our server returns JSON, we can use the json method to parse the result into a Python dictionary, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Tkinter GUI Application Development Blueprints, Second Edition - Second Edition

Tkinter GUI Application Development Blueprints, Second Edition - Second Edition

Bhaskar Chaudhary

Publisher Resources

ISBN: 9781788627481Supplemental Content