# 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.
* **Project-Wide Live Reload:** The dev server watches your **entire project directory**. Change a Python file, a CSS file, or an image, and your browser reloads instantly.
* **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.
* **Flexible & Secure File Serving:** Serve CSS, JS, and images directly from your project root. **No `static` folder required** A built-in security whitelist prevents accidental exposure of sensitive files like `.py` or `.env`.
* **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
# app.py
from syqlorix import *
doc / h1("Hello from Syqlorix!")
doc / 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 Files (CSS, JS, Images)
Syqlorix serves files directly from your project's root directory, making development simple.
**Project Structure:**
```
/my-project/
├── app.py
├── style.css
└── logo.svg
```
**Code:**
```python
# In app.py, link to your files at the root
doc / head(
link(rel="stylesheet", href="/style.css")
)
doc / body(
img(src="/logo.svg", alt="My Logo")
)
```
*The server will find and serve these files automatically and securely. There is no need for a dedicated `static` folder.*
### 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>
## 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` 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/d9/4e/4da71384a5a45e4a169aeb60711a0760bde28b7bcd65cef6dde03da8912f/syqlorix-1.0.9.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* **Project-Wide Live Reload:** The dev server watches your **entire project directory**. Change a Python file, a CSS file, or an image, and your browser reloads instantly.\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* **Flexible & Secure File Serving:** Serve CSS, JS, and images directly from your project root. **No `static` folder required** A built-in security whitelist prevents accidental exposure of sensitive files like `.py` or `.env`.\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 # app.py\n from syqlorix import *\n\n doc / h1(\"Hello from Syqlorix!\")\n doc / p(\"This is a web page generated entirely from Python.\")\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 Files (CSS, JS, Images)\n\nSyqlorix serves files directly from your project's root directory, making development simple.\n\n**Project Structure:**\n```\n/my-project/\n\u251c\u2500\u2500 app.py\n\u251c\u2500\u2500 style.css\n\u2514\u2500\u2500 logo.svg\n```\n\n**Code:**\n```python\n# In app.py, link to your files at the root\ndoc / head(\nlink(rel=\"stylesheet\", href=\"/style.css\")\n)\ndoc / body(\nimg(src=\"/logo.svg\", alt=\"My Logo\")\n)\n```\n*The server will find and serve these files automatically and securely. There is no need for a dedicated `static` folder.*\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</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` 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.0.9",
"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": "7be85fa5445ac02b50ee21856b31d390d8a4b0aad334b197a0470563ef2d11bb",
"md5": "0aa6c6803e38db887d1f3043d53f59d6",
"sha256": "fb8938bbebe55e1b90381ba32287656fdf5e3dc8dd18cc220cc7e3fd49340e2c"
},
"downloads": -1,
"filename": "syqlorix-1.0.9-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0aa6c6803e38db887d1f3043d53f59d6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 16112,
"upload_time": "2025-08-02T09:53:11",
"upload_time_iso_8601": "2025-08-02T09:53:11.785385Z",
"url": "https://files.pythonhosted.org/packages/7b/e8/5fa5445ac02b50ee21856b31d390d8a4b0aad334b197a0470563ef2d11bb/syqlorix-1.0.9-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "d94e4da71384a5a45e4a169aeb60711a0760bde28b7bcd65cef6dde03da8912f",
"md5": "3e10342acab2e11dd4c95e73048c6951",
"sha256": "36b8fc24ca5618f69490d6354749d4c1afbf6f42d11b27db178963631f20f77c"
},
"downloads": -1,
"filename": "syqlorix-1.0.9.tar.gz",
"has_sig": false,
"md5_digest": "3e10342acab2e11dd4c95e73048c6951",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 18079,
"upload_time": "2025-08-02T09:53:12",
"upload_time_iso_8601": "2025-08-02T09:53:12.597374Z",
"url": "https://files.pythonhosted.org/packages/d9/4e/4da71384a5a45e4a169aeb60711a0760bde28b7bcd65cef6dde03da8912f/syqlorix-1.0.9.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-02 09:53:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Syqlorix",
"github_project": "Syqlorix",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "syqlorix"
}