Skip to main content

It is a simple and lightweight web framework built for learning and experimentation purposes.

Project description

BizAPI

A Lightweight Web Framework for Python


Contents


A Simple Example

Installation using a Python package manager:

pip install BizAPI
from bizapi import BizAPI
from bizapi.types import Request, Response

app = BizAPI()


@app.route('/')
def home(request: Request, response: Response):
    response.text = 'This is the home page'
gunicorn main:app

Function-Based Routing

@app.route('/')
def index(request: Request, response: Response):
    response.text = "Hello World!"

Parameterized Routing

@app.route('/say-hello/{name}')
def sayhello(request: Request, response: Response, name: str):
    response.text = f"Assalawma áleykum {name}"

Allowed Methods

@app.route('/article', methods=['POST'])
def create_article(request: Request, response: Response):
    # Create a new article
    pass


@app.route('/article', methods=['GET'])
def get_article(request: Request, response: Response):
    # Get an article
    pass
@app.post('/article')
def create_product(request: Request, response: Response):
    # Create a new article
    pass


@app.get('/article')
def get_product(request: Request, response: Response):
    # Get an article
    pass

Class-Based Routing

@app.route('/article')
class Article:
    def get(request: Request, response: Response):
        # Get an article
        pass
    
    def post(request: Request, response: Response):
        # Create a new article
        pass

Simple Router

def create_article(request: Request, response: Response):
    response.text = "A new article has been created"


app.register_route('/article', create_article, ['POST'])

Templates

from bizapi import render

# First way
@app.route('/say-hello', methods=['GET'])
def home_page(request: Request, response: Response):
    response.body = render('hello.html', title="Say Hello!", name="John")

# Second way
@app.route('/say-hello', methods=['GET'])
def home_page(request: Request, response: Response):
    response.body = render('hello.html', {
        'title': 'Say Hello!',
        'name': 'John'
    })
<!-- File: templates/hello.html -->
<html>
    <head>
        <title>{{title}}</title>
    </head>
    <body>
        <p>Hello {{name}}</p>
    </body>
</html>

Features (To-Do)

Here's a list of upcoming features that will be included in BizAPI:

  • Function-Based Routing
  • Parameterized Routing
  • Allowed Methods
  • Class-Based Routing
  • Simple Routes
  • Templates
  • Static Folder
  • Exception Handler
  • Custom Response
  • Middleware

License
This project is licensed under the MIT License.

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

bizapi-0.0.7.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

BizAPI-0.0.7-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file bizapi-0.0.7.tar.gz.

File metadata

  • Download URL: bizapi-0.0.7.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for bizapi-0.0.7.tar.gz
Algorithm Hash digest
SHA256 9061f9feac39651b5581556e4b676259d601d14fb7523a017f35b1cdde295711
MD5 c8aaabc63a2c5768a96552249cf758a3
BLAKE2b-256 a494fc550fd1f989d7b7fbdec293467db0c94dd6f7a96626a35c9ac50fb6f822

See more details on using hashes here.

File details

Details for the file BizAPI-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: BizAPI-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for BizAPI-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 fb3c814c0b855a10b1c7d3755f91ea935323804c3a1254fc63cf20c4ede1a739
MD5 50eb73c200e33cd569ba3f9500d76dc8
BLAKE2b-256 7e7782d8b6b24beb797f2147d2ef24f5033ef68ed1071dd3c1d9cb36ef11e538

See more details on using hashes here.

Supported by

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