In this tutorial we'll build a deceptively complex looking website. There are four basic parts to the site and we'll set them up in the following order: - postgreSQL RDS hosted on Amazon AWS - python flask controller backbone - flask-RESTFUL API - angular front-end

All of the code can be found in the github repository at

Getting started: the postgresql RDS

Visit and login, or make a free account if you don't already have one. Navigate to the RDS page and launch a DB instance. Select postgresql and make sure that you are choosing an option on the free tier (there should be a toggle that allows you to specify that you only want to view such plans). You'll want to choose the db.t2.micro instance class to remain on the free tier. Remember the settings you specify because they'll be needed to allow your app to instanciate sessions during which it can query.

We will be hosting our app on Heroku, and they require connection via SSL from a hosted app. On the sidebar of your Amazon RDS dashboard, you will select the Parameter Groups tab and change the value of the rds.force_ssl parameter to 1.

Upload your data to the RDS

If you don't have postgreSQL installed on your local machine, you'll need to do that. If you run Ubuntu 16.04 the following commands will get it installed. Upon installation the system account and user postgres is created with the role postgres, which you'll use to use the software.

sudo apt-get install postgresql
sudo su - postgres

To login to your AWS RDS, you'll need enter bash psql -h <host-name> -p 5432 -U <username> -d <DB-name>,

after which, you'll be prompted for your password. Great! Now you should be in. For the purpose of this tutorial, we'll work with a very small amount publically available data from Save the following as courses.csv:

1,To MJ's,4121.92155286,5.07106018066,30.3029463512,-97.7381515503,30.2678149504,-97.7491807938,1,1,1.0
4,Foster City & Back,17815.4307804,30.9269774748,37.5869625258,-122.371044159,37.5417870796,-122.254056931,1,1,1.0
5,Space Invader,14480.4704843,287.742063026,37.7492891258,-122.413798571,37.7496539051,-122.413798571,1,1,0.0
6,It's me Mario!,34914.4291406,490.876060715,37.7643029731,-122.502923012,37.7417301548,-122.503545284,1,1,0.0
10,To VOP,11222.7158059,144.983581543,30.3028722476,-97.738237381,30.2624403675,-97.8022241592,1,1,1.0
11,MV2SF Commute,26645.556405,245.194632955,37.9066555091,-122.556846142,37.7812810646,-122.395838499,1,1,1.0

As you can see, there are 11 columns for which we'll have to specify data types when we copy the table into our DB. Create the table and copy the data into it with the following

  id integer not null,
  name varchar,
  length_in_meters decimal(12),
  elevation_gain_in_meters decimal(12),
  start_lat decimal(8,6),
  start_lon decimal(9,6),
  end_lat decimal(8,6),
  end_lon decimal(9,6),
  route_type integer,
  sub_type integer,
  popularity decimal(2,1)
\copy courses FROM '/home/lee/Downloads/courses.csv' WITH (FORMAT csv, DELIMITER ',', ENCODING 'latin1', QUOTE E'\b', HEADER true)

NEXT UP: Part II - The Python app/api