O'Reilly logo

Tkinter GUI Programming by Example by David Love

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding the new endpoints to our Requester

When the user opens  up a chat window with a friend, our Requester will need to contact the web server to retrieve the conversation history. If there is no conversation history to be obtained, then we will want to initialize the database to prevent errors.

Since initializing the database when it already exists will do nothing, we are safe to call the endpoint even if a database already exists.

We can take advantage of this in our Requester, so that we can skip adding a separate method for initialization and, instead, handle it all when getting the history:

def prepare_conversation(self, user_one, user_two):    endpoint = "/create_conversation_db" params = {"user_one": user_one, "user_two": user_two} ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required