Building cross-platform, easy to maintain software architectures with python, JSON, and javascript

Patrick Farrell
Creative Collisions
3 min readFeb 26, 2018
Photo by Ash Edmonds on Unsplash

Have you ever wanted to create an app or a website? Do you know what an API is? If these are things that are on your mind, this article is for you. If not, bear with me with this one and I’ll be back to posting articles that teach you software from the ground up soon.

In a previous article, I mentioned that python is one of my favorite languages, and the one you should start with to learn coding. I believe this is the case for many reasons, but one of the main reasons is the ease of transferring data between the python backend (the server) and the client front-end (usually the browser).

The need and necessity to create websites in today’s digital world is well known, but the knowledge of how to do it is still lacking. Many people know how to build a website based on wordpress, but they don’t actually know the technologies and system architectures behind what they are building their website on.

Building websites is definitely a complex topic and one that would take way more than a blog post to discuss. But what I want to talk about today is a simple concept of passing data between a server written in python, and a browser application written in Javascript.

Have you heard of the term JSON? It stands for Javascript Object Notation, which is essentially a standard format you can use when passing data or storing data. I have become quite fond of JSON over the past couple years because it is easy to read, but it is also easy to import into python and javascript.

A JSON object looks something like this:

{ “key” : “value” }

In this example, we can take this object represented inside of the curly brackets and find the “value” associated with “key” very easily. The very nice thing about this notation though is that it can be imported into what is called a python dictionary with just one line of code.

This means that when we are coding in python and we receive a string represented in JSON format, we can create a data structure to access that data with very little effort. The same is true in Javascript. So if we want to pass data between python and Javascript, JSON is a great way to do it!

This is how I have build the architectures I have been designing over the past couple of years. On the server side, I build a function that receives a request and verifies that it is in JSON notation. I then load this JSON message into a python dictionary to parse it and make determinations on what operations should be performed on the server based on the message received from the client.

The server then executes any necessary operations and sends a new JSON message back to the client which is typically a browser that can process the incoming message in Javascript. Similar to python, the JSON message is loaded into an object that can be parsed, which in turn can provide information to the user.

As I have written this post, I realize it is going to take a bit more information to describe to you how this architecture actually works. But if this is something you are interested in, please let me know in the comments and I would be happy to dive into the entire server/client architecture of how to use JSON to pass information and commands.

--

--

Patrick Farrell
Creative Collisions

Founder and Business Coach for Online Entrepreneurs and Coaches. I help people create more freedom in their life and connect to their purpose.