A hyper-minimalist Python DSL for generating HTML, CSS, and JS in a single file with live reload and dynamic routing.
Project description
Syqlorix: Build Hyper-Minimal Web Pages in Pure Python
Overview
Syqlorix is a hyper-minimalist Python package for building full HTML documents—including CSS and JavaScript—from a single Python script. It offers a pure Python DSL (Domain-Specific Language) for authoring web interfaces, with a built-in live-reloading server, dynamic routing, and a simple build process.
It is designed for developers who want to create web UIs and simple APIs without leaving the comfort of Python.
Core Design Principles
- All-in-One: Write entire pages in one
.pyfile. - Minimal API: Small surface area, quick to learn.
- Super Readable: Feels like Python, acts like HTML.
- Zero-Config: Sensible defaults for instant productivity.
Key Features
- Pure Python HTML: Generate any HTML element using Python objects and operators.
- Enhanced Live Reload Server: The dev server automatically reloads your browser on code changes across your project, including files in the
static/directory and your main Python script, enabling seamless multi-file development. - Dynamic Routing: Create clean routes with variable paths (e.g.,
/user/<username>). - POST/GET Handling: Easily handle different HTTP methods to process form data.
- JSON API Responses: Return a
dictorlistfrom a route to create an API endpoint. - Static File Serving: Automatically serves files from a
./staticdirectory. - Zero-Config Build: Compile your app into a single, minified HTML file for production.
- Simple CLI: Get started instantly with
init,run, andbuildcommands.
Quick Start
-
Install Syqlorix:
pip install syqlorix
-
Create a file
app.py:# app.py from syqlorix import * doc / h1("Hello from Syqlorix!") doc / p("This is a web page generated entirely from Python.")
-
Run the development server:
syqlorix run app.py
-
Open your browser to
http://127.0.0.1:8000. That's it!
› Click to view Usage Guide
Serving Static Files
Create a folder named static in your project directory. Any files inside it (e.g., static/logo.png, static/custom.css) will be served automatically from the root URL path.
# Reference a static file in your code
doc / img(src="/logo.png", alt="My Logo")
doc / link(rel="stylesheet", href="/custom.css")
Changes to any files within the static directory (e.g., custom.css, logo.png) will automatically trigger a live reload in your browser.
Dynamic Routing
Define routes with variable sections using <var_name> syntax. The captured values are available in request.path_params.
@doc.route('/user/<username>')
def user_profile(request):
username = request.path_params.get('username', 'Guest')
return h1(f"Hello, {username}!")
Handling Forms & POST Requests
Specify which HTTP methods a route accepts with the methods argument. The request object contains form_data for form submissions.
@doc.route('/message', methods=['GET', 'POST'])
def message_form(request):
if request.method == 'POST':
user_message = request.form_data.get('message', 'nothing')
return h1(f"You sent: '{user_message}'")
# On GET request, show the form
return form(
input_(type="text", name="message"), # Use input_ to avoid conflict
button("Submit"),
method="POST"
)
Returning JSON for APIs
Simply return a Python dictionary or list from a route to create a JSON API. Syqlorix automatically sets the correct Content-Type header.
@doc.route('/api/health')
def health_check(request):
return {"status": "ok", "method": request.method}
› Click to view Command-Line Interface (CLI)
Syqlorix comes with a simple and powerful CLI.
-
syqlorix init [filename]Creates a new project file with a helpful template to get you started. Automatically ensures the filename ends with
.py(e.g.,syqlorix init my_appcreatesmy_app.py,syqlorix init page.htmlcreatespage.html.py). Defaults toapp.py.syqlorix init my_cool_app
(This will create
my_cool_app.py) -
syqlorix run <file>Runs the live-reloading development server. It will automatically find an open port if the default is busy.
--port <number>: Specify a starting port (defaults to 8000).--no-reload: Disable the live-reload feature.
syqlorix run app.py --port 8080
-
syqlorix build <file>Builds a single, static HTML file from your script's default state. This command does not execute routes.
--output <filename>or-o <filename>: Set the output file name.--minify: Minifies the HTML and any inline CSS/JS for production.
syqlorix build main.py -o index.html --minify
Target Use Cases
- Fast Prototyping: Quickly mock up web interfaces without juggling multiple files.
- Simple Dashboards: Create internal tools or data visualizations.
- Educational Tools: A clear, Python-only way to demonstrate web fundamentals.
- Simple APIs: Build and serve JSON data from Python scripts.
- Single-File Web Apps: Package an entire web utility into one
.pyfile.
Contributing
Contributions are welcome! Feel free to open issues or submit pull requests on the GitHub repository.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file syqlorix-1.0.4.tar.gz.
File metadata
- Download URL: syqlorix-1.0.4.tar.gz
- Upload date:
- Size: 17.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd68322aa086ee1be9f4170c3ad2dc369e45cdd5d471886a14e090244d1675e7
|
|
| MD5 |
78a83bc174d1328372ca15592f23708c
|
|
| BLAKE2b-256 |
b8c608cc46b8807f34f39f14ac98e1fd63af77fa4a7cf683d9ea1bcbc82484af
|
File details
Details for the file syqlorix-1.0.4-py3-none-any.whl.
File metadata
- Download URL: syqlorix-1.0.4-py3-none-any.whl
- Upload date:
- Size: 14.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5c2f15f7b87113f1bae641712f1e4d9081109289655825d92d1dce3f2382505
|
|
| MD5 |
1d40d6730d95fae423aac3efa0de7f65
|
|
| BLAKE2b-256 |
2553ee210db344550b15e14d10ca2f14c108b593303bd376439f7132cb690384
|