A minimal boilerplate for creating RESTful services using Flask, SQLAlchemy and Flask-RestPlus. This boilerplate has swagger-UI added to it for easy documentation of the endpoints. The boilerplate also has capabilities for adding a database engine to your API services with the help of SQLAlchemy.

What it includes?

  • capabilities of establishhing connection to any database using SQLAlchemy.
  • a service logger for logging all the events, warnings, errors, etc.
  • a placeholder for declaring all your constants.
  • a placeholder for all your declared database models.
  • entire codeset is config-driven.
  • hosting of swagger-UI for your RESTful API’s documentation.
  • hosting multiple namespaces in the routes.
  • a custom response generator for the payloads.

Setting up:

  • install all the requirements from requirements.txt
  • pip install -r requirements.txt
  1. make necessary changes in config.ini
  2. add host address (default=”127.0.0.1”)
  3. add port address (default=5000)
  4. set a name for the flask restful service (default=”flask-minimal-boilerplate”)
  5. add the database url (default=”postgresql://scott:tiger@localhost/sample_db”)
  • create a directory called logs in the current working directory. This is where all your log fiels will be stored.

Directory structure:

Running the program:

  • after having setup everything above, run the program using
  • python run.py
  • Feel free to fork the boilerplate on GitHub for your personal use.