CS 257: Software Design

Getting Started With Flask

Throughout the following discussion, I'm going to assume you're working with Python 3. Most of the instructions work just as well with Python 2, but I won't make any special effort towards Python 2 compatibility.

Whenever I say "yourusername" below, replace it with (can you guess?) your user name.

Web API construction frameworks

Once you have designed a web API, you'll want to write code to implement it, and deploy that code on a publicly accessible server. One of the biggest hassles of API implementation is the of parsing of the URL. For example, if you're implementing queries like "http://wherever.com/authors/Garcia+Marquez", you'll need code to recognize that the caller is requesting the "authors" resource with the author name "Garcia Marquez". Once this information is extracted, you'll probably want to call some sort of get_authors method with the parameter name="Garcia Marquez"--get_authors can then do the job of querying the database and assembling the JSON response to be sent back to the browser/client.

In addition to URL parsing, there are other routine and tedious tasks involved in implementing web services. As a result, many people have devloped "web frameworks"--tools to simplify some of these routine tasks. We will be using one such framework called Flask. Once you have Flask installed and configured, you can focus your attention on the core algorithmic content of your API instead of on repetitive details like URL parsing.

Of course, one of the costs of using extra tools is that you have to install and configure them. That cost is sometimes worth it, and sometimes not, depending on the tool and your needs. The rest of this document is devoted to helping you through the process of setting up and using Flask both on your own computer and on the CS department's computer thacker.mathcs.carleton.edu.

Using Flask on your own computer

Having Flask working on your own machine will help make development of your API more convenient than using the CS department server. Once you have your API working, you'll be able to deploy it to thacker.mathcs.carleton.edu so other people can see your work.

Here's how to get going with Flask on your computer.

Using PostgreSQL on thacker

Using Flask on thacker, Part 1: Moving files

There are many ways to move files from computer to computer over the internet. Here are a few ways to get your files to thacker.

Using Flask on thacker, Part 2: Executing flask apps

Your port

Here are each person's ports for using Flask on thacker.

[Deleted after the term]