Base Python API for a series of on-going recipe learning projects in various front-end frameworks.
Initiate the virtualenv environment:
virtualenv env
source env/bin/activateOnce you have your virtual environment installed, you can use pip to install the dependencies:
pip install -r requirements.txtFollowed by the starting of the server on port 5000 – ensure that it is executable (with chmod +x run_server.sh):
./run_server.shNote that the base Python API uses MongoDB – it attempts to parse the environment variable MONGOHQ_URL, but failing that will attempt to connect to localhost on port 27017. If you'd like to specify the MongoDB credentials then you can export the MONGOHQ_URL environment variable:
export MONGOHQ_URL=mongodb://myUsername:myPassword@myHost:myPort/myDBNameRead:
curl -i http://localhost:5000/recipes
-X GETCreate:
curl -i http://localhost:5000/recipes
-X POST
-H "Content-Type: application/json"
-d '{"name":"Banana Cake","description":"Delectable banana cake!","ingredients":["Banana","Flour"]}'Delete:
Assume that 123456789 is the model's primary key in MongoDB.
curl -i http://localhost:5000/recipes/123456789
-X DELETE