itworksbetter
Seven functions. One loop. Infinite possibilities.
itworksbetter is a tiny Python library that creates a live communication bridge between Python and your browser.
No frameworks. No WebSockets. No async confusion. No frontend setup.
Just:
msg = iwb.catch()
iwb.throw("hello")
That’s it.
Why itworksbetter?
Most browser ↔ Python communication tools are heavy.
You usually need:
- Flask
- FastAPI
- SocketIO
- React/Vue
- Routes
- APIs
- async/await
- frontend tooling
itworksbetter strips all of that away.
You write a single Python loop.
The browser becomes your UI instantly.
Perfect for:
- AI tools
- Browser dashboards
- Python assistants
- Internal tools
- Local automation
- Rapid prototypes
- Teaching
- Experiments
- Live terminals
- Custom browser interfaces
Installation
pip install itworksbetter
The Philosophy
Seven functions.
One loop.
Infinite possibilities.
while True:
if msg := iwb.catch():
iwb.throw(f"You said: {msg['text']}")
That loop is your backend.
Quick Start
10-Line Echo Bot
import time
import itworksbetter as iwb
iwb.lazy(title="Echo Bot", theme="dark")
iwb.init()
while True:
if msg := iwb.catch():
iwb.throw(f"You said: {msg.get('text', '')}")
time.sleep(0.01)
Run it:
python app.py
Your browser opens automatically.
Type messages into the UI.
Python receives them instantly.
How It Works
itworksbetter runs a lightweight local HTTP server.
The browser:
- sends messages to Python
- polls for responses
- displays live output
Internally it uses:
- queues
- threads
- HTTP
- JSON
No external services required.
Everything stays local.
The Seven Functions
1. lazy()
Configure the browser UI before launch.
iwb.lazy(title="My App", theme="light")
Parameters
| Parameter | Type | Default |
|---|---|---|
title |
str |
"itworksbetter" |
theme |
str |
"dark" |
Themes
Supported:
"dark""light"
2. init()
Start the local server and connect to your browser.
iwb.init()
Example
iwb.init(port=8080)
Parameters
| Parameter | Type | Default |
|---|---|---|
port |
int |
8000 |
open |
bool |
True |
auto_fallback |
bool |
True |
Features
- Automatically opens your browser
- Auto-finds an open port if needed
- Runs the server in a background thread
- Cleans itself up on exit
Example Output
✅ Using port: 8000
🚀 itworksbetter v1.0.0 running at http://localhost:8000
📡 Echo Bot | Theme: dark
💡 Waiting for messages...
3. catch()
Receive messages from the browser.
msg = iwb.catch()
Returns
Message received
{"text": "hello"}
No message waiting
None
Typical Usage
if msg := iwb.catch():
print(msg["text"])
4. throw()
Send data to the browser.
iwb.throw("hello")
Supports
Any JSON-serializable data:
iwb.throw("text")
iwb.throw({
"user": "alex",
"online": True
})
iwb.throw([1, 2, 3])
iwb.throw(123)
The browser UI automatically formats and displays the output.
5. close()
Shutdown the server cleanly.
iwb.close()
What it does
- Stops browser polling
- Shuts down the HTTP server
- Frees the port immediately
- Clears message queues
Useful if you want to restart the server without restarting Python.
6. help()
Show a built-in mini guide.
iwb.help()
Displays:
- all functions
- examples
- quick usage tips
Great for learning the API quickly.
7. engine()
Get the JavaScript browser engine.
js = iwb.engine()
This lets you build completely custom browser UIs while still using the same Python communication system.
Custom UI Example
Python
import itworksbetter as iwb
import time
iwb.init()
while True:
if msg := iwb.catch():
iwb.throw({
"reply": msg["text"].upper()
})
time.sleep(0.01)
HTML
<!DOCTYPE html>
<html>
<body>
<input id="msg">
<button id="send">Send</button>
<pre id="output"></pre>
<script>
/* paste iwb.engine() output here */
</script>
<script>
const input = document.getElementById("msg");
const output = document.getElementById("output");
document.getElementById("send").onclick = () => {
itworksbetter.send(input.value);
};
itworksbetter.listen((data) => {
output.textContent += JSON.stringify(data) + "\n";
});
</script>
</body>
</html>
Architecture
The library uses two internal queues:
| Queue | Direction |
|---|---|
_incoming |
Browser → Python |
_outgoing |
Python → Browser |
Communication flow:
Browser → /send → Python queue
Python → /recv → Browser poll
Polling interval:
50msby default
Design Goals
itworksbetter was built to be:
- Minimal
- Easy to learn
- Beginner-friendly
- Fast to prototype with
- Pure Python
- Easy to debug
- Easy to customize
Not a replacement for full production frameworks.
Instead, it focuses on:
- simplicity
- immediacy
- experimentation
- local tools
- rapid development
Example Projects
You can build:
- AI chat interfaces
- Browser terminals
- Live dashboards
- Python control panels
- Automation UIs
- Teaching demos
- Monitoring tools
- Local admin panels
- Game prototypes
- Browser-based utilities
Complete Example
import time
import itworksbetter as iwb
iwb.lazy(
title="Assistant",
theme="dark"
)
iwb.init(port=8000)
while True:
if msg := iwb.catch():
text = msg.get("text", "")
if text == "ping":
iwb.throw({"response": "pong"})
elif text == "time":
iwb.throw({
"time": time.time()
})
else:
iwb.throw({
"echo": text
})
time.sleep(0.01)
Notes
- Everything runs locally
- Uses standard HTTP
- No WebSockets required
- No external dependencies
- Works with any frontend framework
- Browser communication is JSON-based
Version
Current version:
1.0.0
License:
Copyright (c) 2026 Atheer B. Muzzammil
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Most tools make browser communication feel harder than it needs to be.
itworksbetter reduces it down to:
catch()throw()- one loop
And surprisingly, that’s enough for a lot of powerful ideas.
Go build today with itworksbetter!
Metadata
Release files for itworksbetter 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| itworksbetter-1.0.0.tar.gz | 19.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| itworksbetter-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 42.2 kB
Release files / itworksbetter-1.0.0.tar.gz
| Download URL | itworksbetter-1.0.0.tar.gz |
|---|---|
| Size | 19.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
749134dda107bb608a2c8d97c78428809002b3e5445ed57af5696abe75227e51
|
|
BLAKE2b-256 checksum How to use checksums |
966e23567b53b44a4927bc3c818bc98b1bad41eaf1ec3401805e9db049c8c75e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / itworksbetter-1.0.0-py3-none-any.whl
| Download URL | itworksbetter-1.0.0-py3-none-any.whl |
|---|---|
| Size | 23.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9e9e6172b38da04d52293b87071010ec457842a72cce29a8d9e3d040b8abca92
|
|
BLAKE2b-256 checksum How to use checksums |
7552356ee81bd18894d81828b3a41e47b7234b19d08904bd03bec59b10cdcaa7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Security for itworksbetter 1.0.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.