An open API service indexing awesome lists of open source software.

https://github.com/satishdash/flask-rest

A flask based REST project that has simple REST end-points exposed [Based on Python3.5, Flask, MongoDB3.4]
https://github.com/satishdash/flask-rest

flask-restful mongodb pymongo python-3-5

Last synced: 2 months ago
JSON representation

A flask based REST project that has simple REST end-points exposed [Based on Python3.5, Flask, MongoDB3.4]

Awesome Lists containing this project

README

        

# Flask-REST
A flask based REST application Recruiter data store that has simple REST end-points.

* Pre-requisites:
1. Install the required libraries mentioned in `requirements.txt`
2. Install MongoDB >= 3.2

3. Set up access control in MongoDB for this REST based application.

- Create a `` in a separate database, name the database for e.g. `flask`
> E.g. Log into the mongo shell as `` user created already during the installation phase
`` is taken to be the privileged user in the database.

$ mongo -u -p --authenticationDatabase "admin"
> use flask
> db.createUser({ user: "",
pwd: "",
customData: { },
roles: [
{ role: "readWrite", db: "flask" } | "",
...
]
})
> exit

- Create a new `collection` named `credentials` with fields: in the database created above
> You can create as many `credentials` documents in the `credentials` collection.
> E.g. Log into the mongo shell with `` and ``
$ mongo -u -p --authenticationDatabase "flask"
> use flask
> db.credentials.insert({"_id":, "user":"", "password":""})

NOTE: This collection will be used for client authentication to "/auth" to receive a token and proceed with token based authentication and API invocation.

- Create a base64 encoding of the "username:password" while sending a POST reuest to `/auth` for authentication.
> `cuRL` E.g. curl automatically encodes the username:password combination in base64
> curl -v -u ':' -X POST "http://.:/auth"

> For other REST clients ensure to have a base64 encoding (UTF-8) of the `username:password` combination before POSTing to /auth.

4. Edit the `dbconfig.ini` file under "db" with the required properties.
- `mongodb url`
- `db username`
- `db password`
- `db name`
- `credential collection`
- `token collection name`
- `collection name`

* Application Execution:
- Start the server as `python routes.py`

* List of REST end-points:
- To get the list of available REST end-point(s) , send a GET request to: "http://hostname.domain:port/list-apis"