- Fork/clone or clone down this repo
- Create a virtual environment on command line:
virtualenv venv
- Activate in CL with
source venv/bin/activate
- Run
pip3 install -r requirements.txt
- Run
export FLASK_APP=app
andexport FLASK_ENV=development
- You may need to install Flask-SQLAlchemy, Marshmallow, and some other dependencies independently
- To use the app, run
python3 app.py
in CL and query with curl or Postman requests. See the tests and the below docs for templates of good/bad requests.
The testing suite runs on unittest, to see them in action run python3 -m unittest test.py
in the root directory. Tests cover happy/sad paths, showing what a successful request looks like and what an unsuccessful request might look like.
Request
GET http://127.0.0.1:5000/api/v1/county
Response
{ "Number of stored counties": 3193 }
Request
GET http://127.0.0.1:5000/api/v1/county/10003
Response
{
"h_index": 101.1,
"zip": "10003"
}
Request
GET http://127.0.0.1:5000/api/v1/county/happiness_stats/mean?10001&10003&10005
other possibilities:
GET http://127.0.0.1:5000/api/v1/county/happiness_stats/median?10001&10003&10005
GET http://127.0.0.1:5000/api/v1/county/happiness_stats/range?10001&10003&10005
GET http://127.0.0.1:5000/api/v1/county/happiness_stats/stdev?10001&10003&10005
Response
{
"mean": 100.85
}
See Dockerfile
and docker-compose.yml
for an attempt at creating containers. Run docker compose up
to use. I found this would build an image/container, but had less luck on the actual functionality. As far as adding more information to the DB, a user would just need to add data to the preexisting JSON file.