Skip to main content

A hyper-minimalist Python framework for building component-based web UIs and static sites with a pure Python DSL.

Project description

Syqlorix: Build Hyper-Minimal Web Pages in Pure Python

English | Filipino | Cebuano | 简体中文 | 한국어 | Español | Français | Deutsch | 日本語 | Português | Русский

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 powerful static site generator.

It is designed for developers who want to create web UIs, static sites, and simple APIs without leaving the comfort of Python.

Core Design Principles

  • All-in-One: Write entire pages and components in .py files.
  • Component-Based: Structure your UI with reusable, stateful components.
  • High Performance: Native Rust core for critical hot-paths (v1.4+).
  • Zero-Config: Sensible defaults for instant productivity.

Key Features

  • Pure Python HTML: Generate any HTML element using Python objects.
  • Rust-Powered Performance: Blazing fast ID generation and Tailwind CSS processing (up to 15x speedup).
  • Secure Starlark Components: Define UI logic in a deterministic, 100% sandboxed environment.
  • Distributed Scalability: Optional support for high-concurrency Scala backends via Apache Thrift.
  • Component-Based Architecture: Build your UI with reusable components that support props, children, scoped CSS, and lifecycle methods.
  • State Management: Create interactive components with a simple, server-side state management pattern.
  • Live Reload Server: The dev server automatically reloads your browser on code changes.
  • Static Site Generation (SSG): Build your entire application into a high-performance static website.
  • Dynamic Routing: Create clean routes with variable paths (e.g., /user/<username>).

Quick Start

  1. Install Syqlorix:

    pip install syqlorix
    
  2. Create a file app.py:

    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:

    syqlorix run app.py
    
  4. Open your browser to http://127.0.0.1:8000. That's it!


› Click to view Usage Guide

Component-Based Architecture

Syqlorix features a powerful component-based architecture. Components are reusable, stateful, and can have their own scoped styles.

# components.py
from syqlorix import Component, div, h1, p, style

class Card(Component):
    def before_render(self):
        # Lifecycle method: runs before create()
        self.title = self.props.get("title", "Default Title").upper()

    def create(self, children=None):
        # Scoped styles using the component's unique scope_attr (Rust-powered)
        scoped_style = f"div[{self.scope_attr}] h1 {{ color: blue; }}"
        
        return div(
            style(scoped_style),
            h1(self.title),
            *(children or [])
        )

Secure Starlark Components

Use Starlark for deterministic and sandboxed component definitions, ideal for user-generated layouts.

from syqlorix import StarlarkComponent

starlark_ui = """
tag("div", 
    tag("h1", props["title"]),
    tag("p", "Rendered securely via Starlark."),
    class_="container"
)
"""

comp = StarlarkComponent(script_content=starlark_ui, title="Secure UI")

High-Concurrency Backend (Optional)

Delegate rendering to an external Scala backend via Thrift for massive horizontal scaling.

doc = Syqlorix()
# Enable high-performance Scala backend
doc.use_backend(host="127.0.0.1", port=9090)

State Management

class Counter(Component):
    def __init__(self, *children, **props):
        super().__init__(*children, **props)
        try:
            count = int(self.props.get("initial_count", 0))
        except ValueError:
            count = 0
        self.set_state({"count": count})

    def create(self, children=None):
        count = self.state.get("count", 0)
        return div(
            h1(count),
            form(
                button("-", name="count", value=count - 1),
                button("+", name="count", value=count + 1),
                method="get", action="/"
            )
        )

› Click to view Command-Line Interface (CLI)

  • syqlorix init [filename]

    Creates a new project file with a helpful template.
  • syqlorix run <file>

    Runs the live-reloading development server.
  • syqlorix build <file>

    Builds a static version of your site in the dist/ folder.

Target Use Cases

  • Fast Prototyping: Quickly mock up web interfaces without juggling multiple files.
  • High-Performance Static Sites: Optimized build times using the Rust core.
  • Secure Dashboards: Sandboxed component execution via Starlark.
  • Distributed Systems: Web frontends that scale using the Scala backend.

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.4.2.tar.gz (38.7 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.4.2-cp312-cp312-manylinux_2_34_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

File details

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

File metadata

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

File hashes

Hashes for syqlorix-1.4.2.tar.gz
Algorithm Hash digest
SHA256 e609774983690c491d63c7b182498fd0b72b0324ab0b0c051c98b25b5c5282a0
MD5 493a1a756917c286c91d0c8f466d2df8
BLAKE2b-256 8550e41e8c992ffb7f2fd0f367ff79cd659fbb895baa040ee67c1129c152fde8

See more details on using hashes here.

File details

Details for the file syqlorix-1.4.2-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for syqlorix-1.4.2-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 ca8b2037c47fbe7b0a25e3de8a861daadeb78258ec349addb3a7e190aa3f913e
MD5 43cbb697e65c81d222def83613a5ceb2
BLAKE2b-256 27a98966d24dc3bcdd6560cacff179a9b53fe455a0b8d96e13d7cd2e7e7d6405

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