Skip to main content

Muscles WSGI

muscles-wsgi is the WSGI runtime for Muscles. It provides page routing, request/response handling, templates, static files, REST controllers and Swagger UI on top of the shared muscles core.

Installation

pip install muscles-wsgi

Canonical ecosystem install matrix is documented in core: Muscles installation matrix.

  • muscles - core contracts, routing, actions and canonical documentation.
  • muscles-asgi - ASGI runtime with the same application model.
  • muscles-cli - CLI projection and developer commands.
  • muscles-mcp - MCP projection that can also expose WSGI/CLI adapters.
  • muscles-benchmarks - WSGI regression and architecture checks.

Runtime

An app binds Context to WsgiStrategy:

from muscles import ApplicationMeta, Configurator, Context
from muscles.wsgi import WsgiStrategy


class App(metaclass=ApplicationMeta):
    config = Configurator(obj={"main": {"HOST": "0.0.0.0", "PORT": "8080"}})
    context = Context(WsgiStrategy, params={})

    def run(self, *args):
        return self.context.execute(*args, shutup=True)

WsgiStrategy now accepts explicit host and port keyword arguments and uses standard WSGI environment keys such as PATH_INFO, QUERY_STRING and wsgi.url_scheme.

Schema Ownership

WSGI does not ship its own muscles.wsgi.schema_ package. Framework schemas, columns, fields, request/response bodies, security objects and value objects belong to muscles.core.schema and should be imported from muscles:

from muscles import Column, JsonRequestBody, Model, String

ASGI/WSGI Parity

WSGI mirrors the ASGI developer-facing API. An application should be able to switch from AsgiStrategy to WsgiStrategy without changing route groups, OpenAPI metadata, guards, auth overrides, response helpers, file upload handlers or typed handler arguments.

The WSGI package also exposes the same convenience layers:

from muscles.wsgi import MuscularWsgiApp, TestClient, wsgi_app

application = wsgi_app(MuscularWsgiApp())
client = TestClient(application).with_bearer("token")
response = client.post("/api/documents", json={"title": "Spec"})

Use auth=False on a route when a public endpoint such as /api/login lives inside a protected API group.

REST API And Swagger

RestApi registers controllers and actions into the shared route structure. Swagger is generated from those controller schemas, request bodies, parameters and response bodies.

The generated OpenAPI paths include the mounted API prefix. If a controller action is registered as /bookings under prefix /api/v1, the schema exposes /api/v1/bookings.

More detail: docs/openapi-and-routing.md. Backend pipeline features are documented in docs/backend-pipeline.md. Russian documentation: docs/openapi-and-routing.ru.md and docs/backend-pipeline.ru.md.

Request Handling

The request parser supports standard WSGI input and does not require optional system libraries to import. Multipart parsing uses the Python standard library; python-magic is treated as optional.

WSGI strategy uses a persistent server lifecycle on strategy/app level, so route cache is reused across requests while environ/start_response remain strictly per-request state.

Development

Run tests with sibling packages on PYTHONPATH when working from source:

PYTHONPATH=../muscles/src:src python -m pytest -q

Production notes: docs/production.md.

Metadata

Release files for muscles-wsgi 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for muscles-wsgi 2.0.0
File Size Uploaded Provenance Actions
muscles_wsgi-2.0.0.tar.gz 191.4 kB With provenance Details for muscles_wsgi-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for muscles-wsgi 2.0.0
File Interpreter ABI Platform Actions
muscles_wsgi-2.0.0-py3-none-any.whl Python 3 none any Details for muscles_wsgi-2.0.0-py3-none-any.whl

Total release size: 392.8 kB

Release files / muscles_wsgi-2.0.0.tar.gz

Download URL muscles_wsgi-2.0.0.tar.gz
Size 191.4 kB
Tags Source
SHA-256 checksum
How to use checksums
85af10741ce946ce429197fae688b5b9200f00e825d6efc5b182792d120038fc
BLAKE2b-256 checksum
How to use checksums
4a728c15de72136d43b8f6d6648a09e7a198dabe05a0fb1d6ea2e05d5d6e1d58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / muscles_wsgi-2.0.0-py3-none-any.whl

Download URL muscles_wsgi-2.0.0-py3-none-any.whl
Size 201.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c1876285e0fb82ba89c93676096120cbc9303af933e68bd802fe24bf0a64e458
BLAKE2b-256 checksum
How to use checksums
a640a47d0ba56cb0b7ec5263ea4a295d2fefeb38dd1132bf26a811dbd6156dd9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Security for muscles-wsgi 2.0.0

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for muscles_wsgi-2.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page