Skip to main content

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

Syqlorix Logo

PyPI version Python Version License: MIT GitHub issues Discord

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:

    pip install syqlorix
    
  2. 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.")
    
  3. Run the development server:

    syqlorix run app.py
    
  4. 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_app creates my_app.py, syqlorix init page.html creates page.html.py). Defaults to app.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 .py file.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

syqlorix-1.1.30.tar.gz (19.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

syqlorix-1.1.30-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

Details for the file syqlorix-1.1.30.tar.gz.

File metadata

  • Download URL: syqlorix-1.1.30.tar.gz
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.1

File hashes

Hashes for syqlorix-1.1.30.tar.gz
Algorithm Hash digest
SHA256 24a4c2b72624198513ff8d7d2e8ad0c57adb0e7446c237cdd402c786bbf350e8
MD5 b45fff2c28cd3103f11bd2d550ecb995
BLAKE2b-256 2af5f98cc62baffba128bcf4f1aa1d0c23edf817ae69cc4e84fd3e4fe0733bb2

See more details on using hashes here.

File details

Details for the file syqlorix-1.1.30-py3-none-any.whl.

File metadata

  • Download URL: syqlorix-1.1.30-py3-none-any.whl
  • Upload date:
  • Size: 17.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.1

File hashes

Hashes for syqlorix-1.1.30-py3-none-any.whl
Algorithm Hash digest
SHA256 ef1287bab2be3d5059e9244cb2f8db325be272a33d8010b7b4b9f607882b7dfe
MD5 3509039a138e8c9b180d7d6862b078f4
BLAKE2b-256 a7782f74acc858528f2a785032987a6cafc73374b4b7f10452ca3ee396fd30eb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page