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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file muscles_wsgi-1.0.1.tar.gz.
File metadata
- Download URL: muscles_wsgi-1.0.1.tar.gz
- Upload date:
- Size: 190.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77d9f1320cb43ab0537acbd2ee24a49a354670cb0076336d768fec1bcf6859e6
|
|
| MD5 |
6ff17ee2f443df58418b791d40856263
|
|
| BLAKE2b-256 |
698e0dc55fdbe6ccb588a4e377f2d78ad2576ace0dc4583ebde5531d0742c6b8
|
Provenance
The following attestation bundles were made for muscles_wsgi-1.0.1.tar.gz:
Publisher:
release.yml on butkoden/muscles-wsgi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
muscles_wsgi-1.0.1.tar.gz -
Subject digest:
77d9f1320cb43ab0537acbd2ee24a49a354670cb0076336d768fec1bcf6859e6 - Sigstore transparency entry: 2261287532
- Sigstore integration time:
-
Permalink:
butkoden/muscles-wsgi@e1f8032dc0b3e8d8b35b5da89a17785944b0290d -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/butkoden
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e1f8032dc0b3e8d8b35b5da89a17785944b0290d -
Trigger Event:
release
-
Statement type:
File details
Details for the file muscles_wsgi-1.0.1-py3-none-any.whl.
File metadata
- Download URL: muscles_wsgi-1.0.1-py3-none-any.whl
- Upload date:
- Size: 200.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7fdd0b195681dc112eddcb99c7fa24e180fe7596e613431227fbba39e72054b
|
|
| MD5 |
c5db22bf885b26c8fefa249bb2370b39
|
|
| BLAKE2b-256 |
4896d87c8a4fbd5ccbc8e5eeea890fb2cd50e6d7e44e0127362adfa05336164b
|
Provenance
The following attestation bundles were made for muscles_wsgi-1.0.1-py3-none-any.whl:
Publisher:
release.yml on butkoden/muscles-wsgi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
muscles_wsgi-1.0.1-py3-none-any.whl -
Subject digest:
b7fdd0b195681dc112eddcb99c7fa24e180fe7596e613431227fbba39e72054b - Sigstore transparency entry: 2261287707
- Sigstore integration time:
-
Permalink:
butkoden/muscles-wsgi@e1f8032dc0b3e8d8b35b5da89a17785944b0290d -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/butkoden
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e1f8032dc0b3e8d8b35b5da89a17785944b0290d -
Trigger Event:
release
-
Statement type: