A Lightweight Web Framework for Python
Source Code and Information about BizAPI
Contents
Installation
To install BizAPI, use the following command:
pip install BizAPI
Quick Start
Create a simple application using 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'
Run the application using Gunicorn:
gunicorn main:app
Routing
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
You can also use the method-specific decorators:
@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_template
@app.route('/hello')
def hello_page(request: Request, response: Response):
response.html = render_template('hello.html', name="John")
# Second way
@app.route('/say-hello', methods=['GET'])
def home_page(request: Request, response: Response):
response.html = render_template('hello.html', {
'title': 'Say Hello!',
'name': 'John'
})
templates/hello.txt
<html>
<head><title>Hello</title></head>
<body><p>Hello, {{name}}</p></body>
</html>
Exception Handler
Add a custom exception handler to manage errors:
def on_exception(request: Request, response: Response, exc: Exception):
response.text = str(exc)
app.add_exception_handler(on_exception)
Custom Response
BizAPI allows returning different types of responses:
@app.route('/json')
def json(request: Request, response: Response):
response.json = {'message': 'Hello, World'}
@app.route('/text')
def text(request: Request, response: Response):
response.text = "Hello World"
@app.route('/html')
def html(request: Request, response: Response):
response.html = "<h1>Hello, World</h1>"
Middleware
You can add middleware to process requests and responses:
from bizapi.middleware import Middleware
class CustomMiddleware(Middleware):
def request(self, request: Request):
print(f"Request received: {request.path}")
def response(self, request: Request, response: Response):
print(f"Response sent for: {request.path}")
app.add_middleware(CustomMiddleware)
License
This project is licensed under the MIT License.
Metadata
Release files for BizAPI 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bizapi-0.1.1.tar.gz | 7.4 kB | Without provenance | Details for bizapi-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| BizAPI-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for BizAPI-0.1.1-py3-none-any.whl |
Total release size: 15.0 kB
Release files / bizapi-0.1.1.tar.gz
| Download URL | bizapi-0.1.1.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4ec314433e25c2e0e958fa1b0d4d3bf212cc70acb6449ce8c0ee0c0acc444723
|
|
BLAKE2b-256 checksum How to use checksums |
7ee1a1cddf039115dea63a23ea3a5e505208df6d3a51eb7fd187120eec74e1ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.5
|
Release files / BizAPI-0.1.1-py3-none-any.whl
| Download URL | BizAPI-0.1.1-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
88e121c0a60db231d7cded939fb6f4c820700bfab0390db01fa31ee6e89268a9
|
|
BLAKE2b-256 checksum How to use checksums |
a3d0f10d169373bf5d6c509d5a55ee749d4fea2517f820c43754ade8b374690e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.5
|
Security for BizAPI 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.