Seamless is a Python package for creating and manipulating HTML components. It is working similar to React.js, but in Python.
We have detailed documentation here
Installation
pip install python-seamless
Usage
from seamless import Div, H1, P, Component, StyleObject
class MyComponent(Component):
def render(self):
root_style = StyleObject(color="#33343c")
return Div(style=div_style)(
H1(
"Hello, World!",
),
P(
"Welcome to Seamless!"
),
)
from .components import MyComponent
from seamless.renderer import render
@app.get("/")
def hello_world():
return render(MyComponent())
Server actions
It's possible to pass a python function as component props.
The current version works with ASGIApp.
class Person(Component):
def __init__(self, name: str, age: float):
self.age = age
self.name = name
def render(self):
return Form(on_submit=self.save_age)(
Div(f"Update the age for {name}"),
Label(html_for="age")(
"Age: "
),
Input(
type="text",
on_change=self.set_age
),
Button(type="submit")(
"Submit Age"
),
)
def set_age(self, event_data: ChangeEvent):
self.age = event_data.value
def save_age(self, event_data: SubmitEvent):
user = get_user()
user.age = self.age
save(user)
To call a function on the server include this script in your file
<script src="https://cdn.jsdelivr.net/npm/@python-seamless/core@0.8.4/umd/seamless.init.js"></script>
Import the middleware and mount it to your app
from fastapi import FastAPI
from seamless.middlewares import ASGIMiddleware as SeamlessMiddleware
app = FastAPI()
app.add_middleware(SeamlessMiddleware)
You can pass the following config to the middleware to change the socket path of all seamless endpoints.
app.add_middleware(
SeamlessMiddleware,
socket_path="/my/custom/path"
)
Actions use socket.io to communicate between server and client.
TODO
- Add detailed documentation
- Add more tests
- Add support for http actions
Contributing
Feel free to open an issue or a pull request.
Metadata
Release files for python-seamless 0.9.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| python_seamless-0.9.3.tar.gz | 33.7 kB | Without provenance | Details for python_seamless-0.9.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| python_seamless-0.9.3-py3-none-any.whl | Python 3 | none | any | Details for python_seamless-0.9.3-py3-none-any.whl |
Total release size: 130.6 kB
Release files / python_seamless-0.9.3.tar.gz
| Download URL | python_seamless-0.9.3.tar.gz |
|---|---|
| Size | 33.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3dd24ac785b2ae85e863fa38871e2376e4e8bd2450a9500ebd0cec3b5d229c9d
|
|
BLAKE2b-256 checksum How to use checksums |
91fcb497ea5b49a7717e9396079dca935aa6312894793904fa086bcfb0906d53
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.19
|
Release files / python_seamless-0.9.3-py3-none-any.whl
| Download URL | python_seamless-0.9.3-py3-none-any.whl |
|---|---|
| Size | 97.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7b8c757d916ba99546e1f591168539ae1b025d231f7393f13de21e89168a18f8
|
|
BLAKE2b-256 checksum How to use checksums |
fe3d1fef0d9d315d67cf2326c4f1af971a61b4857f4c2caec6e4d3797afc998d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.19
|
Security for python-seamless 0.9.3
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.