python-fasthtml 0.12.30__tar.gz → 0.12.32__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_fasthtml-0.12.30/python_fasthtml.egg-info → python_fasthtml-0.12.32}/PKG-INFO +1 -1
- python_fasthtml-0.12.32/fasthtml/__init__.py +2 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/fasthtml/_modidx.py +1 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/fasthtml/core.py +15 -6
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/fasthtml/jupyter.py +14 -8
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32/python_fasthtml.egg-info}/PKG-INFO +1 -1
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/settings.ini +1 -1
- python_fasthtml-0.12.30/fasthtml/__init__.py +0 -2
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/CONTRIBUTING.md +0 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/LICENSE +0 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/MANIFEST.in +0 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/README.md +0 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/fasthtml/authmw.py +0 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/fasthtml/basics.py +0 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/fasthtml/cli.py +0 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/fasthtml/common.py +0 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/fasthtml/components.py +0 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/fasthtml/components.pyi +0 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/fasthtml/core.pyi +0 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/fasthtml/fastapp.py +0 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/fasthtml/ft.py +0 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/fasthtml/js.py +0 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/fasthtml/katex.js +0 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/fasthtml/live_reload.py +0 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/fasthtml/oauth.py +0 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/fasthtml/pico.py +0 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/fasthtml/starlette.py +0 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/fasthtml/stripe_otp.py +0 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/fasthtml/svg.py +0 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/fasthtml/toaster.py +0 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/fasthtml/xtend.py +0 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/fasthtml/xtend.pyi +0 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/pyproject.toml +0 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/python_fasthtml.egg-info/SOURCES.txt +0 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/python_fasthtml.egg-info/dependency_links.txt +0 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/python_fasthtml.egg-info/entry_points.txt +0 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/python_fasthtml.egg-info/not-zip-safe +0 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/python_fasthtml.egg-info/requires.txt +0 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/python_fasthtml.egg-info/top_level.txt +0 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/setup.cfg +0 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/setup.py +0 -0
- {python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/tests/test_toaster.py +0 -0
|
@@ -80,6 +80,7 @@ d = { 'settings': { 'branch': 'main',
|
|
|
80
80
|
'fasthtml.core._add_ids': ('api/core.html#_add_ids', 'fasthtml/core.py'),
|
|
81
81
|
'fasthtml.core._annotations': ('api/core.html#_annotations', 'fasthtml/core.py'),
|
|
82
82
|
'fasthtml.core._apply_ft': ('api/core.html#_apply_ft', 'fasthtml/core.py'),
|
|
83
|
+
'fasthtml.core._canonical': ('api/core.html#_canonical', 'fasthtml/core.py'),
|
|
83
84
|
'fasthtml.core._find_p': ('api/core.html#_find_p', 'fasthtml/core.py'),
|
|
84
85
|
'fasthtml.core._find_targets': ('api/core.html#_find_targets', 'fasthtml/core.py'),
|
|
85
86
|
'fasthtml.core._find_wsp': ('api/core.html#_find_wsp', 'fasthtml/core.py'),
|
|
@@ -421,6 +421,11 @@ def _part_resp(req, resp):
|
|
|
421
421
|
return resp,kw
|
|
422
422
|
|
|
423
423
|
# %% ../nbs/api/00_core.ipynb
|
|
424
|
+
def _canonical(req):
|
|
425
|
+
if not req.app.canonical: return []
|
|
426
|
+
url = str(getattr(req, 'canonical', req.url)).replace('http://', 'https://', 1)
|
|
427
|
+
return [Link(rel="canonical", href=url)]
|
|
428
|
+
|
|
424
429
|
def _xt_cts(req, resp):
|
|
425
430
|
"Extract content and headers, render as full page or fragment"
|
|
426
431
|
hdr_tags = 'title','meta','link','style','base'
|
|
@@ -428,8 +433,7 @@ def _xt_cts(req, resp):
|
|
|
428
433
|
heads,bdy = partition(resp, lambda o: getattr(o, 'tag', '') in hdr_tags)
|
|
429
434
|
if not is_full_page(req, resp):
|
|
430
435
|
title = [] if any(getattr(o, 'tag', '')=='title' for o in heads) else [Title(req.app.title)]
|
|
431
|
-
|
|
432
|
-
resp = respond(req, [*heads, *title, *canonical], bdy)
|
|
436
|
+
resp = respond(req, [*heads, *title, *_canonical(req)], bdy)
|
|
433
437
|
return _to_xml(req, resp, indent=fh_cfg.indent)
|
|
434
438
|
|
|
435
439
|
# %% ../nbs/api/00_core.ipynb
|
|
@@ -481,12 +485,13 @@ htmx_exts = {
|
|
|
481
485
|
"multi-swap": "https://cdn.jsdelivr.net/npm/htmx-ext-multi-swap@2.0.0/multi-swap.js",
|
|
482
486
|
"path-deps": "https://cdn.jsdelivr.net/npm/htmx-ext-path-deps@2.0.0/path-deps.js",
|
|
483
487
|
"remove-me": "https://cdn.jsdelivr.net/npm/htmx-ext-remove-me@2.0.0/remove-me.js",
|
|
488
|
+
"debug": "https://unpkg.com/htmx.org@1.9.12/dist/ext/debug.js",
|
|
484
489
|
"ws": "https://cdn.jsdelivr.net/npm/htmx-ext-ws@2.0.3/ws.js",
|
|
485
490
|
"chunked-transfer": "https://cdn.jsdelivr.net/npm/htmx-ext-transfer-encoding-chunked@0.4.0/transfer-encoding-chunked.js"
|
|
486
491
|
}
|
|
487
492
|
|
|
488
493
|
# %% ../nbs/api/00_core.ipynb
|
|
489
|
-
htmxsrc = Script(src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.
|
|
494
|
+
htmxsrc = Script(src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.7/dist/htmx.js")
|
|
490
495
|
fhjsscr = Script(src="https://cdn.jsdelivr.net/gh/answerdotai/fasthtml-js@1.0.12/fasthtml.js")
|
|
491
496
|
surrsrc = Script(src="https://cdn.jsdelivr.net/gh/answerdotai/surreal@main/surreal.js")
|
|
492
497
|
scopesrc = Script(src="https://cdn.jsdelivr.net/gh/gnat/css-scope-inline@main/script.js")
|
|
@@ -645,13 +650,17 @@ def ws(self:FastHTML, path:str, conn=None, disconn=None, name=None, middleware=N
|
|
|
645
650
|
return f
|
|
646
651
|
|
|
647
652
|
# %% ../nbs/api/00_core.ipynb
|
|
648
|
-
def _mk_locfunc(f,p):
|
|
653
|
+
def _mk_locfunc(f, p, app=None):
|
|
649
654
|
"Create a location function wrapper with route path and to() method"
|
|
650
655
|
class _lf:
|
|
651
|
-
def __init__(self):
|
|
656
|
+
def __init__(self):
|
|
657
|
+
update_wrapper(self, f)
|
|
658
|
+
self.app = app
|
|
659
|
+
|
|
652
660
|
def __call__(self, *args, **kw): return f(*args, **kw)
|
|
653
661
|
def to(self, **kw): return qp(p, **kw)
|
|
654
662
|
def __str__(self): return p
|
|
663
|
+
|
|
655
664
|
return _lf()
|
|
656
665
|
|
|
657
666
|
# %% ../nbs/api/00_core.ipynb
|
|
@@ -671,7 +680,7 @@ def _add_route(self:FastHTML, func, path, methods, name, include_in_schema, body
|
|
|
671
680
|
if not p: p = '/'+('' if fn=='index' else fn)
|
|
672
681
|
route = Route(p, endpoint=self._endp(func, body_wrap or self.body_wrap), methods=m, name=n, include_in_schema=include_in_schema)
|
|
673
682
|
self.add_route(route)
|
|
674
|
-
lf = _mk_locfunc(func, p)
|
|
683
|
+
lf = _mk_locfunc(func, p, app=self)
|
|
675
684
|
lf.__routename__ = n
|
|
676
685
|
return lf
|
|
677
686
|
|
|
@@ -85,7 +85,7 @@ class JupyUvi:
|
|
|
85
85
|
store_attr(but='start')
|
|
86
86
|
self.server = None
|
|
87
87
|
if start: self.start()
|
|
88
|
-
htmx_config_port(port)
|
|
88
|
+
if not os.environ.get('IN_SOLVEIT'): htmx_config_port(port)
|
|
89
89
|
|
|
90
90
|
def start(self):
|
|
91
91
|
self.server = nb_serve(self.app, log_level=self.log_level, host=self.host, port=self.port, **self.kwargs)
|
|
@@ -110,15 +110,13 @@ class JupyUviAsync(JupyUvi):
|
|
|
110
110
|
self.server.should_exit = True
|
|
111
111
|
wait_port_free(self.port)
|
|
112
112
|
|
|
113
|
+
# %% ../nbs/api/06_jupyter.ipynb
|
|
114
|
+
from starlette.testclient import TestClient
|
|
115
|
+
from html import escape
|
|
116
|
+
|
|
113
117
|
# %% ../nbs/api/06_jupyter.ipynb
|
|
114
118
|
def HTMX(path="/", host='localhost', app=None, port=8000, height="auto", link=False, iframe=True):
|
|
115
119
|
"An iframe which displays the HTMX application in a notebook."
|
|
116
|
-
if isinstance(path, (FT,tuple,Safe)):
|
|
117
|
-
assert app, 'Need an app to render a component'
|
|
118
|
-
route = f'/{unqid()}'
|
|
119
|
-
res = path
|
|
120
|
-
app.get(route)(lambda: res)
|
|
121
|
-
path = route
|
|
122
120
|
if isinstance(height, int): height = f"{height}px"
|
|
123
121
|
scr = """{
|
|
124
122
|
let frame = this;
|
|
@@ -129,9 +127,17 @@ def HTMX(path="/", host='localhost', app=None, port=8000, height="auto", link=Fa
|
|
|
129
127
|
}""" if height == "auto" else ""
|
|
130
128
|
proto = 'http' if host=='localhost' else 'https'
|
|
131
129
|
fullpath = f"{proto}://{host}:{port}{path}" if host else path
|
|
130
|
+
src = f'src="{fullpath}"'
|
|
132
131
|
if link: display(HTML(f'<a href="{fullpath}" target="_blank">Open in new tab</a>'))
|
|
132
|
+
if isinstance(path, (FT,tuple,Safe)):
|
|
133
|
+
assert app, 'Need an app to render a component'
|
|
134
|
+
route = f'/{unqid()}'
|
|
135
|
+
res = path
|
|
136
|
+
app.get(route)(lambda: res)
|
|
137
|
+
page = TestClient(app).get(route).text
|
|
138
|
+
src = f'srcdoc="{escape(page)}"'
|
|
133
139
|
if iframe:
|
|
134
|
-
return HTML(f'<iframe src
|
|
140
|
+
return HTML(f'<iframe {src} style="width: 100%; height: {height}; border: none;" onload="{scr}" ' + """allow="accelerometer; autoplay; camera; clipboard-read; clipboard-write; display-capture; encrypted-media; fullscreen; gamepad; geolocation; gyroscope; hid; identity-credentials-get; idle-detection; magnetometer; microphone; midi; payment; picture-in-picture; publickey-credentials-get; screen-wake-lock; serial; usb; web-share; xr-spatial-tracking"></iframe> """)
|
|
135
141
|
|
|
136
142
|
# %% ../nbs/api/06_jupyter.ipynb
|
|
137
143
|
def ws_client(app, nm='', host='localhost', port=8000, ws_connect='/ws', frame=True, link=True, **kwargs):
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[DEFAULT]
|
|
2
2
|
repo = fasthtml
|
|
3
3
|
lib_name = python-fasthtml
|
|
4
|
-
version = 0.12.
|
|
4
|
+
version = 0.12.32
|
|
5
5
|
min_python = 3.10
|
|
6
6
|
license = apache2
|
|
7
7
|
requirements = fastcore>=1.8.1 python-dateutil starlette>0.33 oauthlib itsdangerous uvicorn[standard]>=0.30 httpx fastlite>=0.1.1 python-multipart beautifulsoup4
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/python_fasthtml.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{python_fasthtml-0.12.30 → python_fasthtml-0.12.32}/python_fasthtml.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|