API implementation
You will work with your web application team for this assignment.
Goals
- Use python, flask, psycopg2, and postgres to implement a full HTTP-based API based on your chosen dataset.
- Practice writing high-quality code.
Rubric
psql < database.sql
1 - config.py is NOT in your repository, and there's a webapp/.gitignore
file that helps make sure it stays that way
1 - API app launches without error using python3 api.py 0.0.0.0 PORT
2 - Quality of API design (see principles and in-class feedback)
2 - Quality of database design (based on principles in readings and videos)
2 - Quality of API documentation returned by /help
7 - Each endpoint responds correctly, as documented in /help
3 - Code qualityYour tasks
Put your up-to-date API design in
doc/api-design.txt.(Forgive me for being ambiguous about this location in the original API design assignment, which I have since corrected. I want this design document to be in your top-level
docfolder. If you need to move some files that you've already committed, you can usegit mv source_file destination_filefollowed by agit committo tell git to move the files.)Put your up-to-date database design (i.e., your
CREATE TABLEstatements) indata/database-schema.sql.(Again, sorry I was unclear about where this file should go in the original database design assignment. It's now clearly stated that I want it in the
datadirectory.)Put a dump of your database in
data/database.sql.Please use a command like this to generate your dump file. If you're on stearns,
DATABASE_NAMEwill be your Unix username. Adjust as needed if you're using postgres on your own computer.pg_dump --clean --no-owner --no-privileges DATABASE_NAME > data/database.sql- Implement your API in Flask. Put your implementation in
webapp/api.py. Any support files (e.g.,templates/help.html) should be inwebappor one of its descendant directories. - Make your API include a
/helpendpoint that generates documentation of the form described in your individual Flask assignment. - Have your API import its database connection information (user, password, database) from
webapp/config.pyas discussed in the psycopg2 lab. - Make sure you have a
webapp/.gitignorefile that prevents yourconfig.pyfrom getting committed to your repo.
How we will test your API
- Login to stearns or do this work locally on our own machine; the difference shouldn't matter.
- Create a
team/config.pyfile with suitable assignments statements fordatabase,user, andpassword. - Grab an up-to-date copy of your repository, and do
git logandgit checkout COMMIT_IDto make sure we are testing your repository in the state it was in at the deadline for this assignment. - Use
psqlandDROP TABLEto clear out all previous tables in our database. - Use
psql < data/database.sqlto load your database into postgres. cd webappand thenpython3 webapp/api.py 0.0.0.0 PORT_OF_OUR_CHOOSING.- Direct a browser to http://localhost:PORT_OF_OUR_CHOOSING/help to read the API documentation.
- Use the browser to test all the advertised features of your API.
- Read your code, look at your database design, check that you met all the specifications, etc.