Image Source: Gemini
[ OOKLEPT ]
( Egg Thief )
|
+----------------+----------------+
| |
[ oo- ] [ -klept ]
(Combining Form) (Combining Form)
| |
Ancient Greek Ancient Greek
ᾠόν (ōión) κλέπτης (kléptēs)
"an egg" "a thief"
ooklept or 'egg thief' refers to Python (🐍) the snake that steals bird's eggs (🪺/🥚).
Here, Python (the programming language) steals HTML and CSS to create a beautiful, strictly-typed Domain-Specific Language (DSL). It also steals PHP's legendary philosophy to let you build full-stack web apps with just raw Python. No template engines, no complex routing files, just pure Python.
🐍 Why Ooklept? The Philosophy
Modern web development often forces you to juggle HTML templates, CSS files, complex routing mechanisms, and JavaScript frameworks.
Ooklept asks a simple question: What if we just used Python?
- The PHP Philosophy (File-Based Routing): In PHP, if you make a file called
about.php, it's instantly available at/about. Ooklept steals this! You drop a Python file in a directory, and it instantly becomes a web route. - Goodbye Template Languages: Jinja and Django templates are great, but they aren't Python. You lose your IDE's autocomplete, type checking, and native syntax. With Ooklept, your HTML is Python.
- Batteries Included Server: Powered by FastAPI under the hood, you don't need to configure a web server to get started.
🚀 Quick Start
Writing a web app in Ooklept is as simple as writing a single script.
Create a file named index.py in your project folder:
# index.py
from ooklept import o
# Globals magically injected by the Ooklept server!
_GET = globals().get("_GET", {})
_POST = globals().get("_POST", {})
username = str(_POST.get("username", ""))
if username:
o.h1("Hello")
o.p(username)
else:
# Use context managers for nesting HTML elements!
with o.form(method="post"):
o.input(name="username", placeholder="User Name")
o.input(type="submit")
Now, serve your app:
python -m ooklept.serve .
Visit http://127.0.0.1:8000 and watch the magic happen!
🏗️ Architecture: How the Magic Works
Ooklept might feel like magic, but it relies on some incredibly clever Python features. Here is a peek under the hood:
1. The HTML Builder (Context Variables)
How does with o.form(): know that o.input() belongs inside it?
Ooklept uses Python's contextvars to keep track of the "current context." When you use the with statement on an element, it temporarily registers itself as the parent. Any new element created inside that with block automatically appends itself to the parent's children.
2. The Server & runpy Execution
When a user requests a URL like /about, FastAPI catches it and finds the about.py file. Instead of treating it like a standard module import, Ooklept uses Python's built-in runpy.run_path().
This allows Ooklept to:
- Execute the script from top to bottom on every request.
- Inject
_GETand_POSTdictionaries directly into the script's global execution state (just like PHP does with$_GETand$_POST). - Capture the top-level HTML tree and render it to a string.
📖 Syntax Guide: Writing HTML in Python
Ooklept provides a massive autogenerated library of HTML tags with full type-hinting support.
Creating Elements
Import o from ooklept. Every tag is a function.
from ooklept import o
o.h1("Welcome to Ooklept")
o.br() # Void tags are handled automatically!
Attributes and Styling
You can chain methods like .attr(), .class_(), and .style() to build complex elements gracefully. Python IDEs will autocomplete valid CSS properties and HTML attributes!
(
o.div()
.class_("container main-layout")
.style(background_color="blue", text_align="center")
.attr(id="hero-banner", data_custom="yes")
)
Note: Because class is a reserved keyword in Python, we use .class_().
Nesting Elements
Use the with statement to build trees of HTML:
with o.div().class_("card"):
o.img().attr(src="avatar.png", alt="User Avatar")
with o.div().class_("card-body"):
o.h2("John Doe")
o.p("Software Engineer")
Security First
You don't need to worry about Cross-Site Scripting (XSS). Ooklept uses html.escape() under the hood for all text and attributes, ensuring your data is safely encoded before it reaches the browser.
🤝 Contributing to Ooklept
Want to help us steal more eggs? We'd love your contributions! Since Ooklept is built to be a lightweight, strictly-typed DSL, here are a few ways you can help:
- Enhance the Server (
serve.py): Help us add things like middleware, static file serving (CSS/JS files), or session management. - Refine Type Hints (
webtypes.py): Our CSS and HTML types are autogenerated, but web standards evolve. Help us keep them accurate. - Build Components: Start building reusable Python functions that return complex UI components (like Modals, Navbars, etc.) using Ooklept tags.
Development Setup
- Clone the repository.
- Ensure you have Python 3.10+ installed (we rely heavily on modern typing features like
UnpackandTypedDict). - Explore
base.pyto understand theElementclass—it's the beating heart of the HTML generator!
Built with ❤️ (and a bit of thievery) for Python developers.
Metadata
Release files for ooklept 1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ooklept-1.1.tar.gz | 1.9 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ooklept-1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 2.0 MB
Release files / ooklept-1.1.tar.gz
| Download URL | ooklept-1.1.tar.gz |
|---|---|
| Size | 1.9 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3b71d63e9625a39e3804320a6ea8b6748c748e412a00865c82e7f710a15e9901
|
|
BLAKE2b-256 checksum How to use checksums |
6fc0d2b38fbc976d61efa89f6474b75ad436061365cbd26e8e3022568bacdac0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Release files / ooklept-1.1-py3-none-any.whl
| Download URL | ooklept-1.1-py3-none-any.whl |
|---|---|
| Size | 155.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b4b5120e9421751bc52103d30737b0bc07b3857c4e520da5a8ad743ccf7a82c8
|
|
BLAKE2b-256 checksum How to use checksums |
f4cb9968afe8211d858c7af7403782c9d833ec3edd1cf95ec0d76d62d6fee7f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|