Skip to main content

Muscles WSGI runtime adapter for Web/API applications

Project description

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.

Related Repositories

  • 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.

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

muscles_wsgi-1.0.0.tar.gz (190.6 kB view details)

Uploaded Source

Built Distribution

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

muscles_wsgi-1.0.0-py3-none-any.whl (200.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: muscles_wsgi-1.0.0.tar.gz
  • Upload date:
  • Size: 190.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for muscles_wsgi-1.0.0.tar.gz
Algorithm Hash digest
SHA256 6e10d35ee40875bc8363ce66aebd1b71e609644263f995232d8891b1160c86c1
MD5 fd74ce3f2484ecdaaf0afc2b64d23583
BLAKE2b-256 fd1b07e68dc8805ac7f6ab44fd1cfe8b8f61b892aaf3344c48831be8dee1df6b

See more details on using hashes here.

Provenance

The following attestation bundles were made for muscles_wsgi-1.0.0.tar.gz:

Publisher: release.yml on butkoden/muscles-wsgi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: muscles_wsgi-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 200.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for muscles_wsgi-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d500b4b3361ec7deadd7e87b56dda5d519b0b49b2247b0a520d4bd32adab32cb
MD5 c9c0d6ceee3e5f1619973acd505f7af1
BLAKE2b-256 7804546c33b4c5abaf47e4b8146f2f1ba6b0abc471f74f4eb1dc550eb6e35ede

See more details on using hashes here.

Provenance

The following attestation bundles were made for muscles_wsgi-1.0.0-py3-none-any.whl:

Publisher: release.yml on butkoden/muscles-wsgi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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