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]
- Host: GitHub
- URL: https://github.com/satishdash/flask-rest
- Owner: satishdash
- Created: 2017-08-03T05:26:03.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-02-02T06:13:27.000Z (over 2 years ago)
- Last Synced: 2025-01-19T07:42:27.839Z (4 months ago)
- Topics: flask-restful, mongodb, pymongo, python-3-5
- Language: Python
- Homepage:
- Size: 11.1 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
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.23. 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"