Recently I've been using things like the PushBullet API to create my version of pushbullet-bash
. I also got interested in the swapi, which is a nice and nerdy implementation of a RESTful API. After working with these I thought it would be useful to know how to make (at least part of) an API. I decided to use the Flask framework for python to make the API. It already comes with a bunch of built in functionality and seemed like it would be easy to pick up.
Set-Up
I am running this right now in a virtual machine on my computer. The virtual machine is running Ubuntu Server and has port forwarding set up for ssh and theoretically the Flask web server (that one still in progress). I did it this way first of all because although I run windows I prefer bash shell and I figured going through every step on the virtual machine would make it easier to redo that later if need be.
Flask
The first step after set up is installing Flask. Simple sudo pip install flask flask-restful
will work. Then I followed a little bit of this blog post and a little bit of this documentation. Bottom line here is my little script as a proof of concept.
Basically right now it will only not 404 when you put in '/SkiResorts' as a GET request. Expanding upon this I want to add connections to MySQL to actually list the SkiResorts. And then once everything is functional the final step would be creating a front end to use the API instead of just curl requests from the terminal. Oh and coming up with some useful data to be requesting.