WSGI, REST API Endpoints, Drawing Inspiration from Literature, and the KISS principle.

Internship, Day 5.

I make my first foray into the world of APIs. It was a day full of stumbling in pitch blackness, but I persevered and gained quite a lot of understanding. Did I get a ton of code working? Heck no. Did I research a lot and have a fuller understanding of how the web works? Yes. Do I feel a bit more confident tackling API’s and writing routes? Yes. Did I fail a lot? Yes. Did I face a major fear today and come out stronger and better? You bet your ass I did.

I had built up in my mind for quite a while that I couldn’t possibly ever understand or work with API’s, that such a thing was far beyond my understanding, that I better leave that up to the smarter, healthier, more capable, and all-around better human programmers than I. It’s been a huge mental block that I’ve built up for myself. Today there was no escaping it; I had to start practical work on understanding REST endpoints, Json, and start to work with APIs. There were several times during my research I got up and walked around when I so completely lost yet again on how to approach my work, and my inner critic was screaming in my mind “You will never get this! You’re a disappointment! Quit now! Go home!” During those times, I recited the Bene Gesserit litany against fear:

“I must not fear. Fear is the mind-killer. Fear is the little-death that brings total obliteration. I will face my fear. I will permit it to pass over me and through me. And when it has gone past I will turn the inner eye to see its path. Where the fear has gone there will be nothing. Only I will remain.”

Frank Herbert, Dune

I took deep breaths. I let it pass over me and through me. And then, nothing.

I went back inside tackled my first time ever writing REST endpoints in a web app. I didn’t get any of them working, but by god, I wrote them. And then re-wrote them. And researched. And errored out. And wrote more. And errored out. And with every error or mistake; I gained more insight.

Here’s a very, very small snapshot of what I’ve figured out.

API endpoints are literally nothing more intimidating than where two applications meet. They are the places API’s go to find what they need. They’re literally a map to what the application is asking for with some built-in instructions. With a REST API, the instructions are the HTTP verb, and the map is the URI.
It’s like me stopping a New Yorker on the street and asking the way to Hell’s Kitchen, and them showing me a map with the end destination, plus directions to get there. The end destination, in a computer’s case, is a URL (i.e./ localhost3306/customers/1) and the direction or command I follow would be an HTTP verb (get). Then, dependent on the patience of the New Yorker (or in a computer’s case, the ability to handle multiple requests), they will either a) keep giving me directions and getting me there or b) tell me to getouttahere! and leave (aka crash out).

we’ve all seen this before

I could be a bit off in my thinking, but so far this is how I’ve worked it out in my head. Just write the routes now, and use the proper instructions.

Also, I found out something exists today I hadn’t heard of, ‘WSGI’. Its the underlying interface between Python web apps and servers. It's great because it allows any Python app to talk to any server (or at least, the vast majority of them) without needing extra dependencies. I’ll be using one for my app, and not using an MVC framework beyond it. Imagine that! They are also able to be built upon and very much customized.

Now, if you already use Django/Flask/etc, you don’t really *need* to know about WSGI, but it's very cool to know what’s going on underneath the hood. Here is a nice and straightforward resource to learn more:

Also, something I’ve realized is that to do things like building a database, write endpoints, get something talking to a server and up and deployed, you don’t *need* a lot of super fancy tools, functionality, and bells and whistles. The more I went on today and tried new things with the code and researched, researched, researched, the more I realized what I’m working on, while certainly not easy, is in fact, quite simple.

And that’s really whats hidden inside the intensity of learning curve; the zen of the entire thing.

Until next time,

-Akira

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store