Skip to main content

Oxi Logo

🚀 OxiServer: The Polyglot Python Web Engine

Write Python once. Deploy it anywhere. At full speed.

OxiServer is a high-performance, polyglot web ecosystem for serving Python applications. It allows you to ship the exact same OxiApp codebase to a 1.45 GB/sec C++ engine, a fast Julia engine, or a pure Python fallback — with zero code changes.

It's not just another ASGI framework. It's a unified server that serves static assets at wire speed, runs CGI and PHP natively, hosts ASGI/WSGI apps, and speaks the ASGI Lifespan protocol flawlessly across three different runtimes.


🌍 The Oxi Ecosystem

Most frameworks lock you into a single runtime. Oxi doesn't. You write your app using standard ASGI/WSGI, and choose your engine at deploy time:

Engine Language Python Mode Static Speed Best For
server C++ Embedded (in-process) 1.45 GB/sec (sendfile) Production, maximum performance
server.jl Julia Subprocess (Unix socket IPC) Near-C speed REPL-driven dev, scientific apps
server.py Python Standalone Pure Python Portability, zero dependencies

All three engines:

  • ✅ Speak ASGI 3.0 and WSGI.
  • ✅ Serve static assets and directory listings.
  • ✅ Execute CGI and PHP out of the box.
  • ✅ Support the ASGI Lifespan protocol.
  • ✅ Run OxiApp, Starlette, FastAPI, Flask, or Django.

⚡ Quickstart

1. Installation

# For the C++ engine (requires a C++ compiler)
git clone https://github.com/sandy98/oxi.git
cd oxi
make

# Standard install (pure Python asyncio)
pip install oxi

# Maximum performance install (adds uvloop)
pip install "oxi[uvloop]"


## 🌍 Run the same app on any engine

### C++ Engine (Embedded CPython, 1.45 GB/sec static throughput)

./server apps.demo:app

### Julia Engine (Unix socket IPC, fast static serving)

julia server.jl apps.demo:app

### Pure Python Engine (Portable, zero compilation)

python3 server.py apps.demo:app

Open `http://localhost:8086` in your browser. The same app, the same routes, three different engines.

## ⚙️ Features

> **The C++ Engine (`server`)**
>
> * **Zero-copy static serving** via `sendfile()`.
> * **Embedded CPython 3.10** : C++ handles the sockets and HTTP parsing, while Python handles the ASGI/WSGI logic.
> * **True Lifespan** : App `on_startup` hooks block C++ socket binding until they complete. App `on_shutdown` hooks are guaranteed to fire on `Ctrl+C`.
> * **Process Isolation** : CGI scripts spawn in their own process groups with strict timeout and memory boundaries.

> **The Framework (`OxiApp`)**
>
> Built on top of the battle-tested **TinA** framework (Tiny Asynchronous).
>
> * **Flask-like routing** : `@app.get("/")`, `@app.post("/")`.
> * **Built-in Sessions & Templating** .
> * **App Mounting** : `app.mount(flask_app, "/admin")` seamlessly integrates WSGI apps inside your ASGI app.
> * **Full Lifespan Decorators** :
>
> from oxi.app import OxiApp
>
> app = OxiApp("My API")
>
> @app.on_startup
> async def connect_db():
> print("🚀 Connecting to database...")
>
> @app.get("/")
> async def index():
> return "Hello from OxiApp!"

> **CGI & PHP (Out of the box)**
>
> Drop a `.py`, `.sh`, `.pl`, `.rb`, `.java`, or `.php` file into `static/cgi-bin/`. OxiServer detects it, spawns the interpreter safely, and parses the CGI `Status:` headers natively.
>
> * No `mod_cgi` configuration.
> * No `php-fpm` setup.

> **📺 Native Video Streaming**
>
> OxiServer is fully RFC 7233 compliant. It supports HTTP Range requests natively in C++, enabling seamless video seeking and streaming in browsers, VLC, and native media players without dropping connections or exhausting memory.

---

## 📊 Benchmarks

Tested on Linux x86_64, serving a 676 KB JPEG file with `wrk -t4 -c100 -d30s`:

| Engine                    | Requests/sec          | Transfer/sec          | Notes                               |
| ------------------------- | --------------------- | --------------------- | ----------------------------------- |
| **OxiServer (C++)** | **2,298 req/s** | **1.45 GB/sec** | Thread-per-connection +`sendfile` |
| Nginx (Reference)         | ~2,400 req/s          | ~1.55 GB/sec          | Epoll event loop                    |
| Apache (mod_php)          | ~800 req/s            | ~500 MB/sec           | Process-per-request                 |

*Note: The C++ engine remains fully responsive to new connections even while under 100% load, and shuts down cleanly in `< 50ms` without dropping active requests.*

## 🏗️ Architecture (Under the Hood)

OxiServer is a **three-tier** system. When a request arrives:

1. **C++ Fast Path** : Checks if the request is a static file or a CGI script. If so, it handles it entirely in C++ using `sendfile` or `posix_spawn()`.
2. **Python Offload** : If the request is dynamic (an ASGI/WSGI route), C++ hands the raw socket file descriptor to the embedded CPython event loop via `asyncio`.
3. **Zero-Copy Bridge** : The Python app reads/writes directly to the socket, completely bypassing the C++ HTTP layer once the handoff is complete.

This hybrid approach means you get the raw network speed of C++ for static files, and the ecosystem of Python for dynamic logic.

## 🛠️ Configuration

Customize OxiServer in  `__about__.py`:

__config__ = {
    "static_dir": "static",
    "cgi_dir": "cgi-bin",
    "index_files": ["index.html", "index.htm", "index.php"],
    "allow_dirlisting": True,
    "allow_cgi": True,
    "max_body_size": 10 * 1024 * 1024,  # 10 MB limit for CGI requests
}

---

## 🗺️ Roadmap

* **☑ **C++ Engine with Lifespan & CGI
* **☑ **Julia Engine with Unix Socket IPC
* **☑ **Python Standalone Engine
* **☑ **ASGI 3.0 & WebSockets
* **☑ **WSGI Adapter (Flask/Django support)
* **□ **HTTP/2 support (coming soon)
* **□ **Multi-worker mode for C++
* **□ **Prometheus metrics endpoint

## License

MIT License. See `LICENSE` for details.

*OxiServer is the evolution of the **TinA** framework. To the original TinA users: thank you for the years of production reliability. Welcome to Oxi.*

Metadata

Release files for oxi 1.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for oxi 1.1.5
File Size Uploaded Provenance Actions
oxi-1.1.5.tar.gz 4.3 MB Without provenance Details for oxi-1.1.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for oxi 1.1.5
File Interpreter ABI Platform Actions
oxi-1.1.5-py3-none-any.whl Python 3 none any Details for oxi-1.1.5-py3-none-any.whl

Total release size: 8.7 MB

Release files / oxi-1.1.5.tar.gz

Download URL oxi-1.1.5.tar.gz
Size 4.3 MB
Tags Source
SHA-256 checksum
How to use checksums
c46e3f60e6dccec9157b0190e0cd3c0d119d6dd610ad93cf90ecc1941b9eb2c0
BLAKE2b-256 checksum
How to use checksums
e3be61fe3c55d343e5b77046375aed406b3219b6a42103c26764a59d0204b5a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.11.0rc1

Release files / oxi-1.1.5-py3-none-any.whl

Download URL oxi-1.1.5-py3-none-any.whl
Size 4.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
163f32d52f96f332394ef4d00f55a595cdc94cc6ae6868f1767f24b2cd7cacc6
BLAKE2b-256 checksum
How to use checksums
ed8d457d53835a8cb56580ca199f650c4b7ea43bf1e681f1b8b435e41dd07231
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.11.0rc1

Security for oxi 1.1.5

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.

Release history Release notifications | RSS feed

This release

1.1.5 This release

2 release files No provenance

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