---
title: "cross-web | pypx"
description: "A library for working with web frameworks"
canonical_url: "https://pypx.app/packages/cross-web"
meta:
  "og:description": "A library for working with web frameworks"
  "og:image": "https://pypx.app/_og/d/h_630%2Cc_PackageCard%2Cname_cross-web%2Cversion_0.9.0%2Csummary_A%2Blibrary%2Bfor%2Bworking%2Bwith%2Bweb%2Bframeworks%2Clicense_MIT%2Cp_Ii9wYWNrYWdlcy9jcm9zcy13ZWIi%2Cs_mKaMyUCQAGbHu_my.png"
  "og:image:height": "630"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "cross-web 0.9.0"
  "twitter:image": "https://pypx.app/_og/d/h_630%2Cc_PackageCard%2Cname_cross-web%2Cversion_0.9.0%2Csummary_A%2Blibrary%2Bfor%2Bworking%2Bwith%2Bweb%2Bframeworks%2Clicense_MIT%2Cp_Ii9wYWNrYWdlcy9jcm9zcy13ZWIi%2Cs_mKaMyUCQAGbHu_my.png"
---

> Index of every page on this site: [llms.txt](https://pypx.app/llms.txt)

# **cross-web**

v0.9.0

A library for working with web frameworks

27 KB Python 3.9+ py3-none-anyMIT1 deps

[**Diff **](https://pypx.app/packages/cross-web/diff)

`$ uv add cross-web`

# 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/`](https://pypx.app/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.

## **Details **

<dl>

<dt>Version</dt>
<dd>0.9.0</dd>

<dt>License</dt>
<dd>MIT</dd>

<dt>Python</dt>
<dd>&gt;=3.9</dd>

<dt>Maintainer</dt>
<dd>Patrick Arminio &lt;patrick.arminio@gmail.com&gt;</dd></dl>

## **Links**

- [Changelog](https://github.com/usecross/cross-web/releases)
- [Homepage](https://github.com/usecross/cross-web)
- [Issues](https://github.com/usecross/cross-web/issues)
- [Repository](https://github.com/usecross/cross-web)
- [View on PyPI](https://pypi.org/project/cross-web/)

## **Release Cadence **

**9**

releases in the past year

avg 40 days between releases

## **Maintainers **

- Patrick Arminio · [patrick.arminio@gmail.com](mailto:patrick.arminio@gmail.com)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://pypx.app/#website","@type":"WebSite","description":"The Python Package Index, reimagined. Fast search, dependency insights, download trends, and changelogs — all in one place.","name":"pypx","url":"https://pypx.app/"},{"@id":"https://pypx.app/packages/cross-web#webpage","@type":"WebPage","description":"A library for working with web frameworks","name":"cross-web","url":"https://pypx.app/packages/cross-web","isPartOf":{"@id":"https://pypx.app/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://pypx.app/packages/cross-web"]}]},{"@id":"https://pypx.app/packages/cross-web#/schema/software-application/1","@type":"SoftwareApplication","applicationCategory":"DeveloperApplication","description":"A library for working with web frameworks","license":"MIT","name":"cross-web","softwareVersion":"0.9.0"}]}
```

## Sitemap

See the full [sitemap](https://pypx.app/sitemap.md) for all pages.
