Skip to main content

A pip package to create Flask RESTful-api seamlessly with customizations

Project description

PyPI version

BadB

BadB Hero image

A pip package to create Flask RESTful-api seamlessly with customizations using a JSON file. With badB one can easily create the basic endpoints required to fullfill the needs of the developer while doing rapid-prototyping.

It comes with a lots of customization which you can do on the go just by tweaking few line in JSON file.

Here JSON file acts like a blueprint for building the whole backend application. One can go from a simple CURD end points to adding authentication to routes of choice seamlessly.

Let's jump right into it to get started...

Getting Started

  • Installing package
pip install badB
  • Once you have installed the package now you can easily access badb command from your terminal everywhere on system.
  • Now create a folder as a dedicated space to project.
  • Open the terminal at that location
  • Just hit badb command on it.

Now you would be welcomed with the BadB wizard which will ask few questions to create the JSON file required to build the endpoints on the go. (To know more on how to answer these questions and create JSON file manually to extend capabilities read this.)

image

Creating the Backend App

Once the JSON file is created or you done with manually creating it. It time to use the badass capability of badB

In order to created app:

  • Open the terminal in project folder
  • Hit the command following command
badb-create-app [filename.json]

Yay! You just created your RESTful-api.
The folder with app name would be created, having all the required Models and a app.py file.

Launch your RESTful-api

To start your api just change directory to your generated app folder and run the following command.

python3 app.py

image

Understanding JSON file: The blueprint

So in order create backend APIs we are storing some information required to create those APIs. Here is the list of parameters and what they do:

Field Description
name Name of the App
prefix The prefix to the api routes. Like /api/route_name
secret This is the app secret used of hashing passwords
schema This field contains the list of tables nested with the variables and there datatypes. One can manually add the constrains and checks and other attributes to these as we usually do in sqlite tables but in key-value pair where key would be name of field and value will be the type with attributes, constraints and checks
auth_config This is an object having all the data configuration required for authetication in app such as:
  • auth key when to true app will implement authentication to selected routes
  • table key containes the table name which will be holding data against which authentication data can be check such as a "user" table. Note: One need to add only tables defined under schema key
  • email_field key will contain a variable define in provide table for authentication above. It's the field name which will be used against to tally the username/email field provided by user during authentication
  • pass_field key also will contain a variable define in provide table for authentication above. It's the field name which will be used against to tally the password field provided by user during authentication
  • auth_routes key will contain object having key-value pair of table and the route methods on which the auth needs to be applied.
  • Here is a example file, which can be taken as a reference to start with: https://github.com/Dev-Akash/BadB/blob/152f0e6f9dc8506db287a6ca8d4d988dc4702c2c/badb.json#L1-L42

    Project details


    Download files

    Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

    Source Distribution

    badb-0.0.8.tar.gz (9.5 kB view hashes)

    Uploaded Source

    Built Distribution

    badb-0.0.8-py3-none-any.whl (8.8 kB view hashes)

    Uploaded Python 3

    Supported by

    AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page