Skip to main content

It is an extension of the bisslog library to support processes with flask

Project description

bisslog-flask

PyPI License: MIT

bisslog-flask is an extension of the Bisslog library to support processes with Flask.
It enables dynamic HTTP and WebSocket route registration from use case metadata, allowing developers to build clean, modular, and metadata-driven APIs with minimal boilerplate.

Part of the Bisslog ecosystem, it is designed to work seamlessly with domain-centric architectures like Hexagonal or Clean Architecture.


✨ Features

  • 🔁 Dynamic route registration for HTTP and WebSocket triggers
  • 🧠 Metadata-driven setup – use YAML or JSON to declare your use cases
  • 🔒 Automatic CORS per endpoint using flask-cors
  • 🔌 Extensible resolver pattern – plug in your own processor
  • ⚙️ Mapper integration – maps HTTP request parts to domain function arguments

📦 Installation

pip install bisslog-flask

🚀 Quickstart

Programmatically

Use this approach if you want to configure the app before Bisslog touches it:

from flask import Flask
from bisslog_flask import BisslogFlask

app = Flask(__name__)
BisslogFlask(
    metadata_file="metadata.yml",
    use_cases_folder_path="src/domain/use_cases",
    app=app
)

if __name__ == "__main__":
    app.run(debug=True)

Or use the factory version:

from bisslog_flask import BisslogFlask

app = BisslogFlask(
    metadata_file="metadata.yml",
    use_cases_folder_path="src/domain/use_cases"
)

if __name__ == "__main__":
    app.run(debug=True)

🖥️ CLI Usage

You can also use the bisslog_flask CLI to run or generate a Flask app.

bisslog_flask run [--metadata-file FILE] [--use-cases-folder-path DIR]
                  [--infra-folder-path DIR] [--encoding ENC]
                  [--secret-key KEY] [--jwt-secret-key KEY]

bisslog_flask build [--metadata-file FILE] [--use-cases-folder-path DIR]
                    [--infra-folder-path DIR] [--encoding ENC]
                    [--target-filename FILE]
  • run: Launches the Flask application from metadata.
  • build: Generates a boilerplate Flask file (flask_app.py by default).

All options are optional. You can override defaults via CLI flags.


🔐 CORS Handling

CORS is applied only when allow_cors: true is specified in the trigger.

Fully dynamic: works even with Flask dynamic routes like /users/<id>.

Powered by @cross_origin from flask-cors.


✅ Requirements

  • Python ≥ 3.7
  • Flask ≥ 2.0
  • bisslog-schema ≥ 0.0.3
  • flask-cors
  • (Optional) flask-sock if using WebSocket triggers

🧪 Testing Tip

You can test the generated Flask app directly with app.test_client() if using the programmatic interface:

from bisslog_flask import BisslogFlask

def test_user_create():
    app = BisslogFlask(
        metadata_file="metadata.yml",
        use_cases_folder_path="src/use_cases"
    )
    client = app.test_client()
    response = client.post("/user", json={"name": "Ana", "email": "ana@example.com"})
    assert response.status_code == 200

If you're generating the code (boilerplate), you just need to test your use cases.


📜 License

This project is licensed under the MIT License.
See the LICENSE file for details.

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

bisslog_flask-0.0.2.tar.gz (31.7 kB view details)

Uploaded Source

Built Distribution

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

bisslog_flask-0.0.2-py3-none-any.whl (21.5 kB view details)

Uploaded Python 3

File details

Details for the file bisslog_flask-0.0.2.tar.gz.

File metadata

  • Download URL: bisslog_flask-0.0.2.tar.gz
  • Upload date:
  • Size: 31.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for bisslog_flask-0.0.2.tar.gz
Algorithm Hash digest
SHA256 27bc16609577a78570505335bd4f26041d1976fefa6d6d5fa658e650fef1da2a
MD5 d46be55dbf1915e1b7e7f6c76ff126f3
BLAKE2b-256 483c5fddb5fbf14bbd880eb8ee438c362b68c09818e8de6b57bd4e836a6f102a

See more details on using hashes here.

File details

Details for the file bisslog_flask-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: bisslog_flask-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 21.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for bisslog_flask-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b2573312ec09bb998c64b8f1d74bb2e327030618f3b710d293f4f0c12ec5a386
MD5 ecd44ef95918f6c3b7555a4c71d127c9
BLAKE2b-256 ad9c5b1749314c7105c482763c3fe3227aa8d2478fc1211268c6fb686d93b265

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