xnano.web
xnano.web
¶
xnano.web
Serve grids and components through an offscreen native cell runtime.
Classes:
-
Web–Serve an application in a browser from an offscreen runtime.
Functions:
-
grid_factory–Normalize a grid instance, class, or callable into a factory.
Web
¶
Serve an application in a browser from an offscreen runtime.
Attributes:
-
state–Application state shared with event and request hooks.
-
title–Browser document title.
-
width–Offscreen viewport width in cells.
-
height–Offscreen viewport height in cells.
-
surface–Presentation surface name.
Example
from xnano.components import Text web = Web(title="Status")
web.run(Text("Ready"), host="127.0.0.1", port=8000)¶
Methods:
-
run–Serve an application until interrupted.
-
close–Stop a managed server when one has been attached.
Source code in xnano/web.py
run
¶
Serve an application until interrupted.
Parameters:
-
source(Any) –Grid/component instance, class, or factory.
-
host(str, default:'127.0.0.1') –Bind address.
-
port(int, default:8000) –Bind port.
Source code in xnano/web.py
close
¶
grid_factory
¶
Normalize a grid instance, class, or callable into a factory.
Parameters:
-
source(Any) –Root grid instance, grid class, or factory.
Returns:
-
tuple[Callable[[], Any], bool, type | None]–Factory, whether the source is shared, and its grid class.
Raises:
-
TypeError–If
sourcecannot produce a grid or component.