# Syqlorix: Build Hyper-Minimal Web Pages in Pure Python
<p align="center">
<img src="https://raw.githubusercontent.com/Syqlorix/Syqlorix/main/syqlorix-logo.svg" alt="Syqlorix Logo" width="250"/>
</p>
<div align="center">
[](https://badge.fury.io/py/syqlorix)
[](https://pypi.org/project/syqlorix/)
[](https://github.com/Syqlorix/Syqlorix/blob/main/LICENSE)
[](https://github.com/Syqlorix/Syqlorix/issues)
[](https://discord.gg/KN8qZh5c98)
</div>
## 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 `.py` file.
* **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 `dict` or `list` from a route to create an API endpoint.
* **Static File Serving:** Automatically serves files from a `./static` directory.
* **Zero-Config Build:** Compile your app into a single, minified HTML file for production.
* **Simple CLI:** Get started instantly with `init`, `run`, and `build` commands.
## Quick Start
1. **Install Syqlorix:**
```bash
pip install syqlorix
```
2. **Create a file `app.py`:**
```python
from syqlorix import *
doc = Syqlorix()
@doc.route('/')
def home(request):
return Syqlorix(
head(title("Hello")),
body(
h1("Hello from Syqlorix!"),
p("This is a web page generated entirely from Python.")
)
)
```
3. **Run the development server:**
```bash
syqlorix run app.py
```
4. Open your browser to `http://127.0.0.1:8000`. That's it!
<br/>
<details>
<summary><h2><strong>› Click to view Usage Guide</strong></h2></summary>
### Serving Static Files
1. Create file `app.py`.
2. Drop any file inside the same directory, e.g. `logo.png`.
3. Reference it from a route handler:
```python
@doc.route('/')
def home(request):
return Syqlorix(
head(
title("Demo"),
link(rel="stylesheet", href="/custom.css")
),
body(
img(src="logo.png", alt="My Logo", width="150")
)
)
```
*Changes to any files within the directory (e.g., `custom.css`, `logo.png`) will automatically trigger a live reload in your browser.*
#### Whitelisting / Blacklisting Static Files with `.syqlorix`
Drop a file named `.syqlorix` in your project root to control which static files are served.
*Rules (one per line):*
- Use glob patterns (`*.pdf`, `docs/**`)
- **Whitelist** (allowed) → write the pattern as-is
- **Blacklist** (blocked) → prefix the pattern with a minus `-`
Example `.syqlorix`:
```
# Allow everything
* # can be a single file too, e.g. - *new-page.py
# Block sensitive or bulky items
- secrets/*
- testings-only/*.py
- *.png
- old-page.py
```
### Dynamic Routing
Define routes with variable sections using `<var_name>` syntax. The captured values are available in `request.path_params`.
```python
@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.
```python
@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.
```python
@doc.route('/api/health')
def health_check(request):
return {"status": "ok", "method": request.method}
```
</details>
<details>
<summary><h2><strong>› Click to view Command-Line Interface (CLI)</strong></h2></summary>
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_app` creates `my_app.py`, `syqlorix init page.html` creates `page.html.py`). Defaults to `app.py`.
```bash
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.
```bash
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.
```bash
syqlorix build main.py -o index.html --minify
```
<details><summary><strong>CLI Reference</strong></summary>
| Command | Purpose |
|---------|---------|
| `syqlorix init [file]` | Scaffolds a ready-to-run template (`app.py` by default) |
| `syqlorix run <file>` | Starts live-reload server on port 8000 (or next free) |
| `syqlorix build <file>` | Outputs a single **static HTML** file (`dist/index.html`) |
Options
- `--port 8080` – start on a specific port
- `--no-reload` – disable live-reload
- `-o file.html --minify` – custom build name + minify
</details>
</details>
## 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 `.py` file.
## Contributing
Contributions are welcome! Feel free to open issues or submit pull requests on the [GitHub repository](https://github.com/Syqlorix/Syqlorix).
## License
This project is licensed under the MIT License - see the [LICENSE](https://github.com/Syqlorix/Syqlorix/blob/main/LICENSE) file for details.
Raw data
{
"_id": null,
"home_page": null,
"name": "syqlorix",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "html, css, javascript, dsl, web, dominate, flask, templating, ui, live-reload, routing, static-server",
"author": null,
"author_email": "\"Karl Benjamin R. Bughaw\" <benjo@pro.space>",
"download_url": "https://files.pythonhosted.org/packages/5e/44/ab8752ccbbbeb6bdb3bedbe547c7402dd4295d189a6947dfa453c9633d0e/syqlorix-1.2.1.tar.gz",
"platform": null,
"description": "# Syqlorix: Build Hyper-Minimal Web Pages in Pure Python\n\n<p align=\"center\">\n <img src=\"https://raw.githubusercontent.com/Syqlorix/Syqlorix/main/syqlorix-logo.svg\" alt=\"Syqlorix Logo\" width=\"250\"/>\n</p>\n<div align=\"center\">\n\n[](https://badge.fury.io/py/syqlorix)\n[](https://pypi.org/project/syqlorix/)\n[](https://github.com/Syqlorix/Syqlorix/blob/main/LICENSE)\n[](https://github.com/Syqlorix/Syqlorix/issues)\n[](https://discord.gg/KN8qZh5c98)\n\n</div>\n\n## Overview\n\n**Syqlorix** is a hyper-minimalist Python package for building full HTML documents\u2014including **CSS** and **JavaScript**\u2014from 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.\n\nIt is designed for developers who want to create web UIs and simple APIs without leaving the comfort of Python.\n\n### Core Design Principles\n\n* **All-in-One**: Write entire pages in one `.py` file.\n* **Minimal API**: Small surface area, quick to learn.\n* **Super Readable**: Feels like Python, acts like HTML.\n* **Zero-Config**: Sensible defaults for instant productivity.\n\n---\n\n## Key Features\n\n* **Pure Python HTML:** Generate any HTML element using Python objects and operators.\n* **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.\n* **Dynamic Routing:** Create clean routes with variable paths (e.g., `/user/<username>`).\n* **POST/GET Handling:** Easily handle different HTTP methods to process form data.\n* **JSON API Responses:** Return a `dict` or `list` from a route to create an API endpoint.\n* **Static File Serving:** Automatically serves files from a `./static` directory.\n* **Zero-Config Build:** Compile your app into a single, minified HTML file for production.\n* **Simple CLI:** Get started instantly with `init`, `run`, and `build` commands.\n\n## Quick Start\n\n1. **Install Syqlorix:**\n ```bash\n pip install syqlorix\n ```\n\n2. **Create a file `app.py`:**\n ```python\n from syqlorix import *\n \n doc = Syqlorix()\n \n @doc.route('/')\n def home(request):\n return Syqlorix(\n head(title(\"Hello\")),\n body(\n h1(\"Hello from Syqlorix!\"),\n p(\"This is a web page generated entirely from Python.\")\n )\n )\n ```\n\n3. **Run the development server:**\n ```bash\n syqlorix run app.py\n ```\n\n4. Open your browser to `http://127.0.0.1:8000`. That's it!\n\n<br/>\n\n<details>\n <summary><h2><strong>\u203a Click to view Usage Guide</strong></h2></summary>\n\n### Serving Static Files\n1. Create file `app.py`. \n2. Drop any file inside the same directory, e.g. `logo.png`. \n3. Reference it from a route handler:\n\n ```python\n @doc.route('/')\n def home(request):\n return Syqlorix(\n head(\n title(\"Demo\"),\n link(rel=\"stylesheet\", href=\"/custom.css\")\n ),\n body(\n img(src=\"logo.png\", alt=\"My Logo\", width=\"150\")\n )\n )\n ```\n\n*Changes to any files within the directory (e.g., `custom.css`, `logo.png`) will automatically trigger a live reload in your browser.*\n\n#### Whitelisting / Blacklisting Static Files with `.syqlorix`\n\nDrop a file named `.syqlorix` in your project root to control which static files are served.\n\n*Rules (one per line):* \n- Use glob patterns (`*.pdf`, `docs/**`) \n- **Whitelist** (allowed) \u2192 write the pattern as-is \n- **Blacklist** (blocked) \u2192 prefix the pattern with a minus `-`\n\nExample `.syqlorix`:\n```\n# Allow everything\n* # can be a single file too, e.g. - *new-page.py\n\n# Block sensitive or bulky items\n- secrets/*\n- testings-only/*.py\n- *.png\n- old-page.py\n```\n\n### Dynamic Routing\n\nDefine routes with variable sections using `<var_name>` syntax. The captured values are available in `request.path_params`.\n\n```python\n@doc.route('/user/<username>')\ndef user_profile(request):\n username = request.path_params.get('username', 'Guest')\n return h1(f\"Hello, {username}!\")\n```\n\n### Handling Forms & POST Requests\n\nSpecify which HTTP methods a route accepts with the `methods` argument. The `request` object contains `form_data` for form submissions.\n\n```python\n@doc.route('/message', methods=['GET', 'POST'])\ndef message_form(request):\n if request.method == 'POST':\n user_message = request.form_data.get('message', 'nothing')\n return h1(f\"You sent: '{user_message}'\")\n \n # On GET request, show the form\n return form(\n input_(type=\"text\", name=\"message\"), # Use input_ to avoid conflict\n button(\"Submit\"),\n method=\"POST\"\n )\n```\n\n### Returning JSON for APIs\n\nSimply return a Python dictionary or list from a route to create a JSON API. Syqlorix automatically sets the correct `Content-Type` header.\n\n```python\n@doc.route('/api/health')\ndef health_check(request):\n return {\"status\": \"ok\", \"method\": request.method}\n```\n\n</details>\n\n<details>\n <summary><h2><strong>\u203a Click to view Command-Line Interface (CLI)</strong></h2></summary>\n\nSyqlorix comes with a simple and powerful CLI.\n\n* #### `syqlorix init [filename]`\n 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_app` creates `my_app.py`, `syqlorix init page.html` creates `page.html.py`). Defaults to `app.py`.\n ```bash\n syqlorix init my_cool_app\n ```\n (This will create `my_cool_app.py`)\n\n* #### `syqlorix run <file>`\n Runs the live-reloading development server. It will automatically find an open port if the default is busy.\n * `--port <number>`: Specify a starting port (defaults to 8000).\n * `--no-reload`: Disable the live-reload feature.\n ```bash\n syqlorix run app.py --port 8080\n ```\n\n* #### `syqlorix build <file>`\n Builds a single, static HTML file from your script's default state. This command does not execute routes.\n * `--output <filename>` or `-o <filename>`: Set the output file name.\n * `--minify`: Minifies the HTML and any inline CSS/JS for production.\n ```bash\n syqlorix build main.py -o index.html --minify\n ```\n\n \n<details><summary><strong>CLI Reference</strong></summary>\n\n| Command | Purpose |\n|---------|---------|\n| `syqlorix init [file]` | Scaffolds a ready-to-run template (`app.py` by default) |\n| `syqlorix run <file>` | Starts live-reload server on port 8000 (or next free) |\n| `syqlorix build <file>` | Outputs a single **static HTML** file (`dist/index.html`) |\n\nOptions \n- `--port 8080` \u2013 start on a specific port \n- `--no-reload` \u2013 disable live-reload \n- `-o file.html --minify` \u2013 custom build name + minify\n\n</details>\n\n</details>\n\n## Target Use Cases\n\n* **Fast Prototyping**: Quickly mock up web interfaces without juggling multiple files.\n* **Simple Dashboards**: Create internal tools or data visualizations.\n* **Educational Tools**: A clear, Python-only way to demonstrate web fundamentals.\n* **Simple APIs**: Build and serve JSON data from Python scripts.\n* **Single-File Web Apps**: Package an entire web utility into one `.py` file.\n\n## Contributing\n\nContributions are welcome! Feel free to open issues or submit pull requests on the [GitHub repository](https://github.com/Syqlorix/Syqlorix).\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](https://github.com/Syqlorix/Syqlorix/blob/main/LICENSE) file for details.\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "A hyper-minimalist Python DSL for generating HTML, CSS, and JS in a single file with live reload and dynamic routing.",
"version": "1.2.1",
"project_urls": {
"Bug Tracker": "https://github.com/Syqlorix/Syqlorix/issues",
"Homepage": "https://github.com/Syqlorix/Syqlorix"
},
"split_keywords": [
"html",
" css",
" javascript",
" dsl",
" web",
" dominate",
" flask",
" templating",
" ui",
" live-reload",
" routing",
" static-server"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "72b8001aa836100a8b7ad3242c78716e294fea46724634324541f95f78d9a758",
"md5": "8f030bfc8e1bb1ff6219d1073b7b2cf5",
"sha256": "420c1975be8bdd892451e904b3bb2c586210f9ff66f92bd6fc8eab3879b9f6b1"
},
"downloads": -1,
"filename": "syqlorix-1.2.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8f030bfc8e1bb1ff6219d1073b7b2cf5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 18395,
"upload_time": "2025-08-21T15:33:36",
"upload_time_iso_8601": "2025-08-21T15:33:36.723420Z",
"url": "https://files.pythonhosted.org/packages/72/b8/001aa836100a8b7ad3242c78716e294fea46724634324541f95f78d9a758/syqlorix-1.2.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "5e44ab8752ccbbbeb6bdb3bedbe547c7402dd4295d189a6947dfa453c9633d0e",
"md5": "d627e16bae94375f10a92dded49852d5",
"sha256": "8f85767d4e2e2cb4c843167c172fb61de380af403f9d394471ea4adfe562ca81"
},
"downloads": -1,
"filename": "syqlorix-1.2.1.tar.gz",
"has_sig": false,
"md5_digest": "d627e16bae94375f10a92dded49852d5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 20879,
"upload_time": "2025-08-21T15:33:38",
"upload_time_iso_8601": "2025-08-21T15:33:38.120198Z",
"url": "https://files.pythonhosted.org/packages/5e/44/ab8752ccbbbeb6bdb3bedbe547c7402dd4295d189a6947dfa453c9633d0e/syqlorix-1.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-21 15:33:38",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Syqlorix",
"github_project": "Syqlorix",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "syqlorix"
}