Skip to main content

Cross

Write once, run everywhere - A universal web framework adapter for Python that lets you write code once and use it across multiple web frameworks.

Installation

uv add cross-web
from cross_web import Response

Overview

Cross provides a unified interface for common web framework operations, allowing you to write framework-agnostic code that can be easily adapted to work with FastAPI, Flask, Django, and other popular Python web frameworks.

Testing

This project is in early development! Cross also ships framework-specific test clients under cross_web.testing.clients.

Import a concrete client from its module:

from cross_web.testing.clients.starlette import StarletteHttpClient
from cross_web.testing.clients.flask import FlaskHttpClient
from cross_web.testing.clients.django import DjangoHttpClient

Do not import client classes from cross_web.testing.clients directly. The package only exports the shared base types so importing it does not pull optional framework dependencies.

The shared testing API lives in cross_web.testing:

from cross_web.testing import HttpClient, Response

Every concrete client exposes the same async interface:

  • await client.request(url, method, headers=None, **kwargs)
  • await client.get(url, headers=None, **kwargs)
  • await client.post(url, data=None, json=None, files=None, headers=None, **kwargs)

Response exposes:

  • response.status_code
  • response.headers
  • response.text
  • response.json

Example

import json

import pytest
from starlette.applications import Starlette
from starlette.requests import Request
from starlette.responses import JSONResponse
from starlette.routing import Route

from cross_web.request._starlette import StarletteRequestAdapter
from cross_web.testing.clients.starlette import StarletteHttpClient


async def echo(request: Request) -> JSONResponse:
    adapter = StarletteRequestAdapter(request)
    body = await adapter.get_body()

    return JSONResponse(
        {
            "method": adapter.method,
            "query": dict(adapter.query_params),
            "body": json.loads(body.decode()),
        }
    )


app = Starlette(routes=[Route("/echo", echo, methods=["POST"])])


@pytest.mark.asyncio
async def test_echo() -> None:
    client = StarletteHttpClient(app)

    response = await client.post("/echo?debug=1", json={"hello": "world"})

    assert response.status_code == 200
    assert response.json == {
        "method": "POST",
        "query": {"debug": "1"},
        "body": {"hello": "world"},
    }

Django

DjangoHttpClient and AsyncDjangoHttpClient take a Django view callable, not a Django app object.

Django must already be configured by your test environment. The recommended setup is pytest-django with a test settings module:

[tool.pytest.ini_options]
DJANGO_SETTINGS_MODULE = "myproject.test_settings"

Available clients

  • cross_web.testing.clients.aiohttp.AiohttpHttpClient
  • cross_web.testing.clients.chalice.ChaliceHttpClient
  • cross_web.testing.clients.django.DjangoHttpClient
  • cross_web.testing.clients.django.AsyncDjangoHttpClient
  • cross_web.testing.clients.flask.FlaskHttpClient
  • cross_web.testing.clients.flask.AsyncFlaskHttpClient
  • cross_web.testing.clients.litestar.LitestarHttpClient
  • cross_web.testing.clients.quart.QuartHttpClient
  • cross_web.testing.clients.sanic.SanicHttpClient
  • cross_web.testing.clients.starlette.StarletteHttpClient

Notes

  • All client methods are async, including clients wrapping sync frameworks.
  • files= uses (filename, content_bytes, content_type) tuples.
  • ChaliceHttpClient supports JSON requests but does not support form data or file uploads.
  • The testing clients are intended for tests and integration-style handler checks, not as production HTTP clients.

Documentation website

The repository now includes a Cross-Docs-powered website in website/.

cd website
just setup
just dev

That setup uses cross-docs for the Python side, @usecross/docs on the frontend, the Inertia Vite plugin, and Inertia v3 packages.

Metadata

Release files for cross-web 0.8.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 cross-web 0.8.0
File Size Uploaded Provenance Actions
cross_web-0.8.0.tar.gz 336.4 kB Without provenance Details for cross_web-0.8.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cross-web 0.8.0
File Interpreter ABI Platform Actions
cross_web-0.8.0-py3-none-any.whl Python 3 none any Details for cross_web-0.8.0-py3-none-any.whl

Total release size: 363.2 kB

Release files / cross_web-0.8.0.tar.gz

Download URL cross_web-0.8.0.tar.gz
Size 336.4 kB
Tags Source
SHA-256 checksum
How to use checksums
9d694807f343e8f550c68d28552bd81fbc31a84d6c3951a94f7c1d16a204e798
BLAKE2b-256 checksum
How to use checksums
46117bce1550b1fac475253886a9690683a3665cea24787fd1f17fe49fba53cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / cross_web-0.8.0-py3-none-any.whl

Download URL cross_web-0.8.0-py3-none-any.whl
Size 26.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aec202df6a53685a222b8ef7642d86cf2bbbea707597be531b3bc9ee3785c516
BLAKE2b-256 checksum
How to use checksums
10d77b69970de3e91938a2a03630f430de952308aff90651de19bbeb2db0b488
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for cross-web 0.8.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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