Skip to main content

Add your description here

Project description

Logo

Intro

Hypie, pronounced "high-pie", is a python library for building web frontends, built on top of _hyperscript, a scripting language for the web made by the htmx folks, and htpy, a library for generating HTML in python.

The goal of hypie is to be able to code powerful web frontends, server-side rendered or client-side rendered (or a mix of both), without having to leave python, or switch your favorite backend, using relatively little abstractions and no reactivity.

New README in the process, for now enjoy this counter example:

import htpy
import hypie as hp


class CounterWidget(hp.ServerComponent):
    initial_count: int = 0

    def template(self):
        count_var = hp.var(":count")

        return htpy.div[
            htpy.button(
                _=hp.hs(
                    hp.set_(count_var, to=self.initial_count),
                    hp.On("click")[
                        hp.set_(count_var, to=count_var + 1),
                        hp.set_(hp.me.textContent, to=f"Count is: {count_var}"),
                    ],
                )
            )[f"Count is: {self.initial_count}"]
        ]


@hp.style(CounterWidget)
def counter_style():
    return {
        "button": {
            "background-color": "#4A90D9",
            "color": "#ffffff",
            "border": "none",
            "border-radius": "6px",
            "padding": "10px 20px",
            "font-size": "16px",
            "font-weight": "600",
            "cursor": "pointer",
            "transition": "background-color 0.2s ease",
        },
        "button:hover": {"background-color": "#3A7BC8"},
    }
hypie build -i ./app/CounterWidget.py -o ./app/static

(or your favourite backend)

import pathlib

import htpy
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
from fastapi.responses import HTMLResponse


from .CounterWidget import CounterWidget


app = FastAPI()

app.mount(
    "/static", StaticFiles(directory=pathlib.Path(__file__).parent.resolve() / "static")
)


@app.get("/")
def counter_example(count: int = 0):
    return HTMLResponse(
        htpy.html[
            htpy.head[
                htpy.link(),
                htpy.link(rel="stylesheet", href="/static/_hypie_styles.css"),
                htpy.script(src="https://cdn.jsdelivr.net/npm/hyperscript.org@0.9.93"),
                htpy.title["Counter Example"],
            ],
            htpy.body[CounterWidget(count)],
        ]
    )

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

hypie-0.1.1.dev5.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

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

hypie-0.1.1.dev5-py3-none-any.whl (24.4 kB view details)

Uploaded Python 3

File details

Details for the file hypie-0.1.1.dev5.tar.gz.

File metadata

  • Download URL: hypie-0.1.1.dev5.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for hypie-0.1.1.dev5.tar.gz
Algorithm Hash digest
SHA256 67cffbec00621dab8dfafe00573e57b5fd58f22f5e48ab13fd30ce9f3f4baba8
MD5 d8634714c46c15b857f8c91f4192560f
BLAKE2b-256 0141e50b6afdc28373d6c13168427d76a07b258fbc245bd09a2c1838df6c24ab

See more details on using hashes here.

File details

Details for the file hypie-0.1.1.dev5-py3-none-any.whl.

File metadata

  • Download URL: hypie-0.1.1.dev5-py3-none-any.whl
  • Upload date:
  • Size: 24.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for hypie-0.1.1.dev5-py3-none-any.whl
Algorithm Hash digest
SHA256 76421810c9d59f9b1abb2cc9337c9f098ef48d01ea4744739b12c507e2165fd8
MD5 f609fee701abf483308fdd47c770628e
BLAKE2b-256 3a1282e8b7b8375392e37a0f7f8838e7208873aa71f3287210b0ec735929f646

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