Skip to main content

Python SDK for Blazor Microfrontends

Project description

Blazor Microfrontends Python SDK

A Python SDK for integrating Python microfrontends with Blazor applications.

Installation

  1. Create a virtual environment:
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install the SDK:
pip install -e .

Usage

App Shell Configuration

  1. Initialize an app shell:
blazor-mf appshell init --name "MyAppShell" --version "1.0.0"
  1. Add a microfrontend to the app shell:
blazor-mf appshell add "my-microfrontend" "http://localhost:5000" "/my-path"
  1. List all microfrontends:
blazor-mf appshell list

Microfrontend Development

  1. Initialize a new microfrontend:
blazor-mf microfrontend init --name "MyMicrofrontend" --version "1.0.0"
  1. Add routes to your microfrontend:
blazor-mf microfrontend add-route "/dashboard" "DashboardComponent"
  1. List all routes:
blazor-mf microfrontend list-routes

Flask Integration

from flask import Flask, render_template
from blazor_microfrontends import MicrofrontendApi, microfrontend_route

app = Flask(__name__)
api = MicrofrontendApi(__name__)

@microfrontend_route(api, "/dashboard", "DashboardComponent")
@app.route('/dashboard')
def dashboard():
    return render_template('dashboard.html')

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

Django Integration

from django.shortcuts import render
from blazor_microfrontends import MicrofrontendApi, microfrontend_route

api = MicrofrontendApi(__name__)

@microfrontend_route(api, "/dashboard", "DashboardComponent")
def dashboard(request):
    return render(request, 'dashboard.html')

Configuration

App Shell Configuration (appshell.yaml)

name: MyAppShell
version: 1.0.0
microfrontends:
  - name: dashboard
    url: http://localhost:5000
    path: /dashboard
  - name: profile
    url: http://localhost:5001
    path: /profile

Microfrontend Configuration (microfrontend.json)

{
  "name": "MyMicrofrontend",
  "version": "1.0.0",
  "routes": [
    {
      "path": "/dashboard",
      "component": "DashboardComponent"
    }
  ]
}

Development

  1. Install development dependencies:
pip install -e ".[dev]"
  1. Run tests:
pytest
  1. Format code:
black .
  1. Run type checking:
mypy .

License

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

blazor_microfrontends_python-1.0.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

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

blazor_microfrontends_python-1.0.0-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file blazor_microfrontends_python-1.0.0.tar.gz.

File metadata

File hashes

Hashes for blazor_microfrontends_python-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b2beeb1fd261d751f1aabc62158e4129667a09d1b51928d01575c71853613c62
MD5 5d997707731d52e86439cdd201648678
BLAKE2b-256 5e99c0ddda4825f5567e9dff147b979b2cc7ff75242e6bf2effa1c8e30ac206b

See more details on using hashes here.

File details

Details for the file blazor_microfrontends_python-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for blazor_microfrontends_python-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0e95a3282844e44c19ff20455acc2ae71f3ff99a43faa8258c8fa116fffdde15
MD5 3cdbfa8558a58308b2c7e6a7f11b377b
BLAKE2b-256 6b697382128e20d1393b9e61cb096793f4a40946a3caaf0392be5dc679752171

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