API
Install
NOTES
You will need access to the everycook DB (see Everycook’s github documentation). For now settings are hardcoded in the file simple_api.py, you will need to change the DB config in there in the following line
engine = create_engine(
'mysql://root:root@localhost/ec',
encoding='ISO-8859-1',
convert_unicode=True)
Clone the repo where you want to install the app
cd /where/you/want/to/install
git clone https://github.com/abondis/everycook-api.git
Install system dependencies
apt-get build-dep python-mysqldb python-virtualenv
Virtualenv
Create aThis will allow us to install needed python libraries without touching the system ones.
virtualenv env
Virtualenv
Activate thePutting us in the isolated environment
. env/bin/activate
Install python libraries in the activated environment
pip install -U distribute
pip install -r requirements.txt
Test run the app
python recipes.py
Init script (to run as a daemon)
Edit daemon settings in the file ‘everycook_api’
APP_DIR=/vagrant/everycook-api
VIRTUALENV_DIR=$APP_DIR/env
ACTIVATE=$VIRTUALENV_DIR/bin/activate
PID_FILE=$VIRTUALENV_DIR/everycook.pid
HOST=''
PORT=8000
START_CMD="gunicorn simple_api:app --daemon -n everycookapi -p $PID_FILE --chdir $APP_DIR -b $HOST:$PORT"
Copy or link the file ‘everycook_api’ to your initscript folder
cp everycook_api /etc/init.d/
Run everycook_api
/etc/init.d/everycook_api start
Stop everycook_api
/etc/init.d/everycook_api stop
Access
List all recipes
http://127.0.0.1:8000/api/recipes
Get recipe’s details with rec_id=4
http://127.0.0.1:8000/api/recipes/4
list recipe’s steps
/api/recipes/4 /api/steps?rec_id=4
list ingredients
http://127.0.0.1:8000/api/ingredients