##Pylthon Flask API Template-- Salaries for employees in City of Chicago. Please observe any Copyright changes.
Modified from Naren Arya's Flask tutorial: https://impythonist.wordpress.com/2015/07/12/build-an-api-under-30-lines-of-code-with-python-and-flask/
3. Extract 'app.py' 'employee_chicago.csv' and 'Instructions.txt' into the new folder "Salaries", or just clone the repo and skip steps 1 and 2.
#$
mkdir rest-app
cp app.py rest-app
cp employee_chicago.csv rest-app
cd rest-app #Sets to 'app root directory'
sqlite3 salaries.db
# #If 'salaries.db' is trusted and loaded into app root directory already
# #ATTACH DATABASE 'salaries.db' As 'salaries'; # as alt
# #DETACH DATABASE 'salaries.db'
# #Create table named "salaries"
#### # Note 'primary key' deletes duplicates on import
# sqlite>
create table salaries (
NAME text,
POSITION text,
DEPARTMENT text,
SALARY double
);
# Load csv data into salaries table
# sqlite>
.mode csv
.import employee_chicago.csv salaries
# Should print out names 'last, first middle initial'
# sqlite>
SELECT name FROM salaries;
ATTACH DATABASE 'salaries.db' As 'salaries';
# Next: 'Ctrl-D' quit out of sqlite3 from terminal
# Make virtual environment with name "rest-api"
# $
virtualenv rest-api
source rest-api/bin/activate # Source into virtual environment for pip inst.
# Note: sudo aptitude install build-essential # for C / C++ compiler
# For error free install (we use sudo after build-essential:)
# (rest-api)$
sudo pip install flask
sudo pip install flask-restful
sudo pip install sqlalchemy
#(rest-api) ~/Salaries/rest-app$
sudo python app.py
#http://localhost:5000/departments
#http://localhost:5000/dept/police
#http://localhost:5000/dept/family%20&%20support # "%20&%20" denotes " & "
# (rest-api)
deactivate