Skip to main content

PyDOM

pydom-logo

Simple to learn, easy to use, fully-featured UI library for Python

PyPI Version Supported Python Versions

PyDOM is a Python library that allows you to create web pages using a declarative syntax.

PyDOM provides a set of components that represent HTML elements and can be composed to create complex web pages.

Quick Start

This is a quick start guide to get you up and running with PyDOM. The guide will show you how to setup PyDOM and integrate it with FastAPI.

Installation

First, install the PyDOM package.

pip install pydom

Create Reusable Page

PyDOM provides a default page component that is the minimal structure for a web page.

The page can be customized by extending the default page component and overriding the head and the body methods.

More information about the default page component can be found here.

# app_page.py

from pydom import Link, Page

class AppPage(Page):
      def head(self):
        return (
          *super().head(),
          Script(
            src="https://cdn.tailwindcss.com/",
          )
        )

Creating the FastAPI app

Lastly, create the FastAPI app and add an endpoint that will render the page when the user accesses the root route.

# main.py

from fastapi import FastAPI
from fastapi.responses import HTMLResponse
from pydom import render, Div, P

from app_page import AppPage

app = FastAPI()

@app.get("/", response_class=HTMLResponse)
async def read_root():
    return render(
        AppPage(
            Div(classes="text-center p-4 rounded")(
                Div(classes="text-4xl")(
                    "Hello, World!"
                ),
                P(classes="text-lg text-gray-600")(
                    "Welcome to PyDOM"
                ),
            )
        )
    )

if __name__ == "__main__":
    import uvicorn
    uvicorn.run(app, host="localhost", port=8000)

That's it! Now you can run the app and access it at http://localhost:8000/.

It should display a page like this:

Quick Start

Documentation

The full documentation can be found at our documentation site.

Metadata

Release files for pydom 0.4.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pydom 0.4.2
File Size Uploaded Provenance Actions
pydom-0.4.2.tar.gz 48.7 kB Without provenance Details for pydom-0.4.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pydom 0.4.2
File Interpreter ABI Platform Actions
pydom-0.4.2-py3-none-any.whl Python 3 none any Details for pydom-0.4.2-py3-none-any.whl

Total release size: 195.3 kB

Release files / pydom-0.4.2.tar.gz

Download URL pydom-0.4.2.tar.gz
Size 48.7 kB
Tags Source
SHA-256 checksum
How to use checksums
16a8cb23521cf74ede09b35e61f968b65313c16697d320f2018b123e494eb1ce
BLAKE2b-256 checksum
How to use checksums
788097eb94f3558daf1fa8f17ea621115265c9a5e82610d4f17bca49694d21a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / pydom-0.4.2-py3-none-any.whl

Download URL pydom-0.4.2-py3-none-any.whl
Size 146.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1ab495bb98a6ad1f69aa8c4442ae94fe9b152cb9dd99783685810d917c5b917e
BLAKE2b-256 checksum
How to use checksums
fc08f8cd4775661fffeff7cef4c3ee1bd9099d3fa5b8ed4bbc0f02133920111c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Security for pydom 0.4.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page