Weather API Repository
Project Question
-
Platform: Project (Weather API)
-
User story: As an API user I want to get min, max, average and median temperature and humidity for given city and period of time and store the data in a database.
-
Requirements for submission:
-
Fork this Repository to get started.
-
Use git for version control.
-
Publish your final codebase on a public GitHub repository or send us a compressed codebase with your answers, please avoid using 'Yoyo Wallet' in repo name or description
-
On completion email the details to [email protected]
-
Functionality:
-
Create locally running RESTful web API;
-
Use the flask-framework provided on this repo, create an API that accepts a request with 'city' and 'period' args;
-
Fetches weather data for that location and period of time from some public API e.g. Yahoo! Weather;
-
Stores the data in Local Postgres database (Simple Weather table to be setup in the models folder)
-
Computes min, max, average and median temperature and humidity for that location and period and returns that to the user;
-
Extra goals: Provide a view which renders a bar chart for the requested data; e.g. Daily average temperature over the last 7 days
-
Additional Notes: Optimize and fix any errors so the code works on local
- clone the repo
- install a virtual env and activate it:
virtualenv --no-site-packages env; source env/bin/activate - install requirements:
pip install -r requirements.txt
- Copy 'example.development.cfg' file from the config folder
- Paste in the same config folder and rename the new file 'development.cfg'
- Update any local credentials in this new file if required
Setup the PostgreSQL database (minimum version 9.6.*)
psql -U postgres
=# CREATE USER weather WITH PASSWORD 'weather';
=# CREATE DATABASE weather;
=# GRANT ALL PRIVILEGES ON DATABASE weather TO weather;
=# \q
Construct your db app-side:
from weather.models import db
from weather.models.seeds import seed_db
run 'python rebuild_db.py'
run 'python app.py runserver'
- Python 3.6.*
- PostgresSQL 9.6.*