Skip to main content

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

    Metadata

    Release files for badB 0.0.8

    For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

    Source distribution (sdist)

    Source distribution for badB 0.0.8
    File Size Uploaded
    badb-0.0.8.tar.gz 9.5 kB Details

    Built distribution (wheel)

    Table of built distributions (wheels) for badB 0.0.8
    File Interpreter ABI Platform
    badb-0.0.8-py3-none-any.whl Python 3 none any Details

    Total release size: 18.3 kB

    Release files / badb-0.0.8.tar.gz

    Download URL badb-0.0.8.tar.gz
    Size 9.5 kB
    Tags Source
    SHA-256 checksum
    How to use checksums
    1376b25a1fee1274d866899727ea06bcddb3d319f32ef4a6febe1a7239a2e532
    BLAKE2b-256 checksum
    How to use checksums
    7297489fb033bf43fd01927d241e63a8ed1c7143b90c3b18ffb966a617e016f8
    Upload date
    Uploaded using Trusted Publishing?
    What is trusted publishing?
    No
    Uploaded via twine/5.0.0 CPython/3.11.3

    Release files / badb-0.0.8-py3-none-any.whl

    Download URL badb-0.0.8-py3-none-any.whl
    Size 8.8 kB
    Tags Python 3
    SHA-256 checksum
    How to use checksums
    5e4d6e6c8a3782ffe1a01ef9b98e444fff200d29119ed1e48d2b7ab9a2381fd6
    BLAKE2b-256 checksum
    How to use checksums
    3c6276f6eeb9ca2e551ba646147590ea0af9a9cbfa12ff7d7bbad6da892125d4
    Upload date
    Uploaded using Trusted Publishing?
    What is trusted publishing?
    No
    Uploaded via twine/5.0.0 CPython/3.11.3

    Release history Release notifications | RSS feed

    This release

    0.0.8 This release

    2 release files

    0.0.7

    2 release files

    0.0.6

    2 release files

    0.0.5

    2 release files

    0.0.4

    2 release files

    0.0.3

    2 release files

    0.0.2

    2 release files

    0.0.1

    2 release files

    Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page