Skip to main content

The Next.js like Python framework

Project description

b9ui is a lightweight framework for building HTML pages with a component approach similar to Next.js. It is designed so that developers need to write almost no JavaScript to create dynamic web services.

[!]

The framework is in a very early development/testing phase. There are currently a lot of half-functioning features. We welcome your contributions to help progress!

Requirements

python = "^3.12" ludic = "^0.4.0"

Installation


pip install “b9ui”

Similar to Starlette, you will also want to set up an ASGI server:


pip install uvicorn

Full Example

app/layout.py:

from typing import override
from b9ui.attrs import NoAttrs 
from b9ui.components import Component
from b9ui.html import html, head, body, div, link, script, title
from b9ui.types import AnyChildren


class Layout(Component[AnyChildren, NoAttrs]):
    @override
    def render(self) -> html:
        return html(
            head(
                title("Hello, World! App"),
                link(href="/static/css/default.css", rel="stylesheet"),
            ),
            body(
                div(
                    div(
                        div(
                            div(
                                div(*self.children,
                                    class_="pb-24 flex flex-col justify-between w-full"
                                ),                                
                                class_="w-full flex justify-center"
                            ),
                            class_="py-16 overflow-auto flex flex-row"
                        ),                                                
                        class_="app text-stone-700 dark:text-gray-100 bg-white dark:bg-stone-900 min-h-screen"
                    ),
                    class_="display: contents"
                ),                
                script(src="https://unpkg.com/htmx.org@1.9.10"),
                script(src="https://unpkg.com/hyperscript.org@0.9.12"),                
                script(src="https://cdn.tailwindcss.com"),
                class_="min-h-screen bg-background font-sans antialiased __className_aaf875",
            ),
            class_="light",
            lang="en", style="color-scheme: light;"
        )

app/page.py:

from b9ui.components import Blank
from b9ui.html import div, p


async def index() -> Blank:
    return Blank(
        div(
            p("Hello, World!"),
        ),        
    )

To run the application:

uvicorn b9ui.app:app --reload

More Examples

For more complex usage that includes the full capabilities of the framework, please visit the folder with examples [on GitHub] (https://github.com/b9ui/b9ui/tree/master/examples/).

Contributing

Any contribution to the framework is welcome! Your help will make it a better resource for the community. If you are ready to contribute, read [contribution guidelines] (https://github.com/b9ui/b9ui/tree/master/CONTRIBUTING.md).

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

b9ui-0.2.0.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

b9ui-0.2.0-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file b9ui-0.2.0.tar.gz.

File metadata

  • Download URL: b9ui-0.2.0.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Darwin/23.5.0

File hashes

Hashes for b9ui-0.2.0.tar.gz
Algorithm Hash digest
SHA256 664115d442507af21e6102ae94587382243134580c5545c9a22a47c62b4b77dd
MD5 dbf3c0dcfd48a4bbf8ca164dca6b9f51
BLAKE2b-256 8adf0245ba1a64e1f848497301aca1fd0ceef6b1e96e98c79b563fdffb75018f

See more details on using hashes here.

File details

Details for the file b9ui-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: b9ui-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 22.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Darwin/23.5.0

File hashes

Hashes for b9ui-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 385a1189f5e0a61d6a5baaec3925f75d15a42be192c072f38de5bf53be1f6739
MD5 faab6e4f7fb3c90b90cf6daf6484f053
BLAKE2b-256 e4c8b86af2a5dc6188c444ddafeb790e9b455c6fae5113997e0c3b684c238621

See more details on using hashes here.

Supported by

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