Skip to content

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

Notifications You must be signed in to change notification settings

satishdash/Flask-REST

Repository files navigation

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 <REST user> in a separate database, name the database for e.g. flask

      E.g. Log into the mongo shell as <root> user created already during the installation phase <root user> 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: <user,password> in the database created above

      You can create as many credentials documents in the credentials collection. E.g. Log into the mongo shell with <REST user> and <REST user password> $ 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:

About

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published