Code Monkey home page Code Monkey logo

county_stats's Introduction

County Stats

Setup (requires python3 and pip3)

  1. Fork/clone or clone down this repo
  2. Create a virtual environment on command line: virtualenv venv
  3. Activate in CL with source venv/bin/activate
  4. Run pip3 install -r requirements.txt
  5. Run export FLASK_APP=app and export FLASK_ENV=development
  6. You may need to install Flask-SQLAlchemy, Marshmallow, and some other dependencies independently
  7. 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.

Testing

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.


Available Endpoints

GET number of all county entries

Request

GET http://127.0.0.1:5000/api/v1/county

Response

{ "Number of stored counties": 3193 }


GET the happiness index for a specific county

Request

GET http://127.0.0.1:5000/api/v1/county/10003

Response
{
    "h_index": 101.1,
    "zip": "10003"
} 

GET the specified statistic from 2 or more counties (mean, median, range, stdev)

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
}

Containers

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.


Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.