File: app.py

package info (click to toggle)
python-trame 3.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 101,620 kB
  • sloc: python: 13,515; sh: 183; javascript: 93; makefile: 7
file content (37 lines) | stat: -rw-r--r-- 884 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from pathlib import Path

from trame.app import get_server
from trame.ui.html import DivLayout

module = {
    "serve": {
        "tailwind": str(Path(__file__).parent.resolve()),
    },
    "scripts": [
        "tailwind/tailwind.js",
    ],
}

HTML_CONTENT = Path(__file__).with_name("content.html").read_text()
CLASSES = "bg-white dark:bg-gray-900 dark:before:fixed dark:before:-z-50 dark:before:inset-0 dark:before:bg-gray-950/50"


class App:
    def __init__(self, server=None, table_size=10):
        self.server = get_server(server, client_type="vue3")
        self.server.enable_module(module)
        self._build_ui()

    def _build_ui(self):
        with DivLayout(self.server) as layout:
            layout.root.classes = CLASSES
            layout.root.add_child(HTML_CONTENT)


def main():
    app = App()
    app.server.start()


if __name__ == "__main__":
    main()