cross-web
Cross-web is a Python library (version 0.4.1) providing a unified interface for common web framework operations, allowing developers to write framework-agnostic code for popular Python web frameworks like FastAPI, Flask, and Django. It is actively developed with recent releases addressing bug fixes and framework support, and was last updated in January 2026.
Warnings
- breaking The package name and import path changed from `lia-web` to `cross-web` in version 0.4.0. Code using `from lia_web import ...` will need to be updated.
- deprecated The `lia-web` package is now deprecated. It acts as a compatibility shim for `cross-web` but should not be used for new projects or ongoing development.
- gotcha Pydantic was removed as a dependency in version 0.2.2. If your application implicitly relied on Pydantic being a dependency of `cross-web` (e.g., for schema validation outside of `cross-web`'s explicit use), it might break.
- gotcha A fix for handling multipart form data in the AioHTTP integration was introduced in version 0.2.1. Older versions might have issues with file uploads or on-demand processing.
Install
-
pip install cross-web
Imports
- Response
from cross_web import Response
- Request
from cross_web import Request
Quickstart
from cross_web import Request, Response
def my_framework_agnostic_handler(request: Request) -> Response:
# This function represents a handler written using cross-web's abstractions
name = request.query_params.get('name', 'World')
body_content = f"Hello, {name}! This is a cross-web response."
return Response(
status_code=200,
headers={'Content-Type': 'text/plain'},
body=body_content.encode('utf-8')
)
# --- Example of how a web framework adapter might use it ---
# In a real application, a framework-specific adapter would create
# the Request object and handle the Response object.
# Simulate an incoming request
simulated_request = Request(
method="GET",
path="/greeting",
headers={
"Host": "example.com",
"User-Agent": "curl/7.81.0"
},
query_params={
"name": "cross-web user"
},
body=b''
)
# Call the framework-agnostic handler
response_obj = my_framework_agnostic_handler(simulated_request)
# Output the response details (what a framework adapter might send back)
print(f"Status: {response_obj.status_code}")
print(f"Headers: {response_obj.headers}")
print(f"Body: {response_obj.body.decode('utf-8')}")