Skip to main content

MetaMessage protocol integrations for Python web frameworks

Project description

mm-web

MetaMessage protocol integrations for Python web frameworks.

This monorepo provides three packages:

  • mm-core - Shared types, errors, and HTTP client SDK (framework-agnostic)
  • mm-fastapi - FastAPI integration with MMRouter, MMMiddleware, and route decorators
  • mm-flask - Flask integration with MMFlask, MMMiddleware, and route decorators

What is MetaMessage?

MetaMessage is a binary serialization protocol that provides efficient encoding/decoding of structured data. It follows the convention:

  • GET/DELETE requests: Parameters are hex-encoded as ?data=<hex> query parameter
  • POST/PUT/PATCH requests: Body is binary MetaMessage
  • Responses: Always binary MetaMessage

Packages

mm-core

Shared framework-agnostic code:

  • CONTENT_TYPE_METAMESSAGE - Content type constant (application/metamessage)
  • MMEncoderError / MMDecoderError - Encoding/decoding error classes
  • MMClient / AsyncMMClient - Synchronous and asynchronous HTTP clients

mm-fastapi

from fastapi import FastAPI
from mm_fastapi import MMRouter

app = FastAPI()
router = MMRouter(app)

@router.get("/users")
async def list_users(req: User) -> User:
    return User(name=req.name, age=req.age)

@router.post("/users")
async def create_user(req: User) -> User:
    return User(name=req.name, age=req.age)

mm-flask

from flask import Flask
from mm_flask import MMFlask, MMMiddleware

app = Flask(__name__)
MMMiddleware(app)
mm = MMFlask(app)

@mm.get("/users")
def list_users(req: User) -> User:
    return User(name=req.name, age=req.age)

@mm.post("/users")
def create_user(req: User) -> User:
    return User(name=req.name, age=req.age)

Installation

Install all packages

pip install -e ".[dev]"

Install specific framework extras

# FastAPI
pip install -e ".[fastapi]"

# Flask
pip install -e ".[flask]"

Testing

pip install -e ".[dev]"
pytest tests/ -v

Project Structure

src/
├── mm_core/           # Shared types, errors, client SDK
├── mm_fastapi/        # FastAPI integration
└── mm_flask/          # Flask integration
tests/
├── mm-fastapi/        # FastAPI tests
└── mm-flask/          # Flask tests
examples/
├── mm-fastapi/        # FastAPI examples
└── mm-flask/          # Flask examples

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

mm_web-0.1.0.tar.gz (97.8 kB view details)

Uploaded Source

Built Distribution

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

mm_web-0.1.0-py3-none-any.whl (32.5 kB view details)

Uploaded Python 3

File details

Details for the file mm_web-0.1.0.tar.gz.

File metadata

  • Download URL: mm_web-0.1.0.tar.gz
  • Upload date:
  • Size: 97.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for mm_web-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6f63166964c28d02daf26fb6f67f8f97c84a1ba46f863a7102fe82aa91e4cae2
MD5 b252dbd18e0b4e199ad8ea872c5aa137
BLAKE2b-256 6ac5615de9d795d0672629b9a32ccc7a5e3c8a2dbdd7b5773294bde478c62b18

See more details on using hashes here.

File details

Details for the file mm_web-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mm_web-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 32.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for mm_web-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 05fe1b96d93d2186c852c6dbcb1c1214537fc157efc9e4c645d90bb76f2c7f5b
MD5 22da46d3b6e13a4ad63096df7777dc50
BLAKE2b-256 c428350c245186f7086b8c0829541cbf0b0bb009bf9023f859ee35c9e06eab82

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