A homework for H2O.ai, based on REQUIREMENTS.md
A UNIX-like system with:
- Python 2.7
- pipenv
- GNU make
- clone repository
- in the cloned directory, run
make install
It should create a virtualenv with Python 2.7, install all the dependencies and a pre-commit hook.
make lint
should execute the pycodestyle
(former PEP8) checks on the code.
make test
should execute the py.test
and genarate spec-like output (using pytest-spec)
make run
should start Flask API instance:
$ make run
pipenv run src/app.py
* Serving Flask app "Reuters API" (lazy loading)
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: on
* Running on http://127.0.0.1:9666/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
/article/<newid>
- returns article bynewid
primary key/articles[?filter1=value&filter1=value]
- returns a list of articles, optionally filtered by the filters:- exact match filters:
cgisplit
lewissplit
newid
topics
oldid
- list filters (field should have all values):
meta.companies
meta.exchanges
meta.orgs
meta.people
meta.places
meta.topics
- full-text filters (field should contain text):
text.body
text.dateline
text.title
- date filters (article date should match one of):
day
- same day of monthmonth
- same monthyear
- same yeardate
- same date
- exact match filters:
Get article number 100 (i.e. newid
is 100):
curl http://127.0.0.1:9666/article/100
Get all articles from 1987:
curl http://127.0.0.1:9666/article\?year\=1987
Get all articles about USA, Iran and Reagan from 1987:
curl http://127.0.0.1:9666/article\?year\=1987\&meta.people\=reagan\&meta.places\=iran
Get all articles about USA, Iran and Reagan from 1987 which mention Texas:
curl http://127.0.0.1:9666/article\?year\=1987\&meta.people\=reagan\&meta.places\=iran\&text.body\=Texas