# 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>
## 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
# 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 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.
```python
# 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`.
```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",
"author": null,
"author_email": "\"Karl Benjamin R. Bughaw\" <benjo@pro.space>",
"download_url": "https://files.pythonhosted.org/packages/52/d6/7474e8b838ebed0ba03f3660e35e2811febae93ccc72c93cc5f7e4c72d75/syqlorix-1.0.2.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\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 # 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 Static Files\n\nCreate 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.\n\n```python\n# Reference a static file in your code\ndoc / img(src=\"/logo.png\", alt=\"My Logo\")\ndoc / link(rel=\"stylesheet\", href=\"/custom.css\")\n```\n\n*Changes to any files within the `static` directory (e.g., `custom.css`, `logo.png`) will automatically trigger a live reload in your browser.*\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.2",
"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"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "d84564b8585101cda3a49f8a7a85495c4fba50889622cc53c0d7ecc7bc41b005",
"md5": "ec770b8c540ecef316ee81be903b4dd6",
"sha256": "c582eb20d419b9b3aa4c9998957a07c6b43de9fc2c96978f50da1573274d7b1b"
},
"downloads": -1,
"filename": "syqlorix-1.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ec770b8c540ecef316ee81be903b4dd6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 14588,
"upload_time": "2025-07-09T13:57:35",
"upload_time_iso_8601": "2025-07-09T13:57:35.778870Z",
"url": "https://files.pythonhosted.org/packages/d8/45/64b8585101cda3a49f8a7a85495c4fba50889622cc53c0d7ecc7bc41b005/syqlorix-1.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "52d67474e8b838ebed0ba03f3660e35e2811febae93ccc72c93cc5f7e4c72d75",
"md5": "8838ee7a9cb8a2f8908ce7cf0e687ab4",
"sha256": "e64007d6be8d5bf0f5fdf25f8309171937f026283dc7b8f28e0214d3c2b68587"
},
"downloads": -1,
"filename": "syqlorix-1.0.2.tar.gz",
"has_sig": false,
"md5_digest": "8838ee7a9cb8a2f8908ce7cf0e687ab4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 16611,
"upload_time": "2025-07-09T13:57:37",
"upload_time_iso_8601": "2025-07-09T13:57:37.107643Z",
"url": "https://files.pythonhosted.org/packages/52/d6/7474e8b838ebed0ba03f3660e35e2811febae93ccc72c93cc5f7e4c72d75/syqlorix-1.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-09 13:57:37",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Syqlorix",
"github_project": "Syqlorix",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "syqlorix"
}