https://github.com/joyytoo/yummyrecipes-flaskapi
A yummy recipes python flask Application that helps you keep track of your recipes.
https://github.com/joyytoo/yummyrecipes-flaskapi
flask flask-restplus flask-sqlalchemy nosetests postgresql python
Last synced: 5 months ago
JSON representation
A yummy recipes python flask Application that helps you keep track of your recipes.
- Host: GitHub
- URL: https://github.com/joyytoo/yummyrecipes-flaskapi
- Owner: JoyyToo
- Created: 2017-10-25T16:18:37.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-12-07T23:48:45.000Z (over 3 years ago)
- Last Synced: 2025-02-04T15:48:06.151Z (over 1 year ago)
- Topics: flask, flask-restplus, flask-sqlalchemy, nosetests, postgresql, python
- Language: Python
- Homepage: https://yummy-recipe-flaskapi.herokuapp.com/
- Size: 141 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# YummyRecipes-flaskAPI
[](https://travis-ci.org/JoyyToo/YummyRecipes-flaskAPI) [](https://coveralls.io/github/JoyyToo/YummyRecipes-flaskAPI) [](https://www.codacy.com/app/JoyyToo/YummyRecipes-flaskAPI?utm_source=github.com&utm_medium=referral&utm_content=JoyyToo/YummyRecipes-flaskAPI&utm_campaign=Badge_Grade)
A Flask RESTful API with Endpoints that enable users to:
- Register, login and manage their account.
- Create, update, view and delete a category.
- Add, update, view or delete recipes.
- Enable logging of data manipulation timestamps.
## Example request with response
```
Curl
curl -X POST --header 'Content-Type: multipart/form-data' --header 'Accept: application/json' -F username=user1 -F password=useruser -F email=user%40mail.com 'http://127.0.0.1:5000/api/v1/auth/auth/register'
Request URL
http://127.0.0.1:5000/api/v1/auth/auth/register
Response Body
{
"message": "You registered successfully. Please log in.",
"status": "success"
}
Response Code
201
Response Headers
{
"date": "Thu, 07 Dec 2017 12:53:49 GMT",
"server": "Werkzeug/0.12.2 Python/2.7.12",
"content-length": "87",
"content-type": "application/json"
}
```
## Prerequisites
Python 2.6 or a later version
## Virtual environment
Create virtual environment:
```
$ sudo pip install virtualenv
$ virtualenv venv
```
Activate virtual environment:
```
$ source .venv/bin/activate
```
## Dependencies
Install all package requirements in your python virtual environment.
```
pip install -r requirements.txt
```
## Env
Rename .env.sample into .env
## Testing
To set up unit testing environment:
```
$ pip install nose
```
To execute a test file:
```
$ source .env
$ nosetests
```
## Testing API
*Note* After user login, ensure you specify the generated token in the header:
- In postman header **key** : `token` **value** :
- While testing on the browser, key in the `` in Authorize header.
## Initialize the database
You need to initialize database and tables by running migrations.
```
python manager.py db init
python manager.py db migrate
python manager.py db upgrade
```
## Start The Server
Start the server which listens at port 5000 by running the following command:
```
source .env
python run.py
```
## Pagination
The API enables pagination by passing in *page* and *limit* as arguments in the request url as shown in the following example:
```
http://127.0.0.1:5000/category?page=1&limit=10
```
## Searching
The API implements searching based on the name using a GET parameter *q* as shown below:
```
http://127.0.0.1:5000/category?q=example
```
### Api endpoints
| url | Method| Description| Authentication |
| --- | --- | --- | --- |
| /register | POST | Registers new user | FALSE
| /login | POST | Handles POST request for /auth/login | FALSE
| /logout | POST | Logs out a user | TRUE
| /reset-password | POST | Reset user password | FALSE
| /new-password/| POST | Enter new password | FALSE
| /category | GET | Get every category of logged in user|TRUE
| /category/{category_id} | GET | Get a single category|TRUE
| /category | POST | Create a new category|TRUE
| /category/{category_id} | PUT | Update a single category|TRUE
| /category/{category_id} | DELETE | Delete a single category|TRUE
| /category/{category_id}/recipes | POST | Creates a recipe|TRUE
| /category/{category_id}/recipes/{_id} | GET | Gets a single recipe|TRUE
| /category/{category_id}/recipes/{_id} | PUT | Updates a single recipe|TRUE
| /category/{category_id}/recipes/{_id} | DELETE | Deletes a single recipe|TRUE
### Testing and API documentation
You can test using postman
[https://yummy-recipe-flaskapi.herokuapp.com/](https://yummy-recipe-flaskapi.herokuapp.com/)