computersciencenerd
computersciencenerd

Reputation: 13

Can I connect a Python GUI to a website using HTTP?

Is there a way to connect to a website from a Python Tkinter GUI using HTTP requests? Essentially, I want the following functionality:

  1. Press a button on the GUI
  2. A signal is sent to a website (from the GUI) that this button was pressed
  3. Send information along with that signal

I only need to focus on the GUI side of this. I have no code to go along with this - I was just wondering if it's even possible.

Upvotes: 0

Views: 1044

Answers (1)

Tim Roberts
Tim Roberts

Reputation: 54743

There are three components to what you ask. Your GUI can send information to your web server using some URL you would have to invent. It can be as simple as:

import requests
requests.get("http://example.com/information?name=Joe+Smith")

Then, your web server needs to respond to that request by saving the information somewhere. Your web server also needs a similar request to return the information. Then, your web page needs Javascript on a timer doing an AJAX request to fetch that info, and to change some field on the page in response. That depends on what Javascript tools you're using.

Upvotes: 1

Related Questions