python-fasthtml 0.14.14__tar.gz → 0.14.16__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.
Files changed (38) hide show
  1. {python_fasthtml-0.14.14/python_fasthtml.egg-info → python_fasthtml-0.14.16}/PKG-INFO +1 -1
  2. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/fasthtml/__init__.py +1 -1
  3. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/fasthtml/_modidx.py +1 -0
  4. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/fasthtml/core.py +11 -5
  5. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/fasthtml/core.pyi +1 -1
  6. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/fasthtml/xtend.py +3 -2
  7. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16/python_fasthtml.egg-info}/PKG-INFO +1 -1
  8. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/CONTRIBUTING.md +0 -0
  9. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/LICENSE +0 -0
  10. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/MANIFEST.in +0 -0
  11. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/README.md +0 -0
  12. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/fasthtml/authmw.py +0 -0
  13. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/fasthtml/basics.py +0 -0
  14. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/fasthtml/cli.py +0 -0
  15. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/fasthtml/common.py +0 -0
  16. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/fasthtml/components.py +0 -0
  17. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/fasthtml/components.pyi +0 -0
  18. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/fasthtml/fastapp.py +0 -0
  19. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/fasthtml/ft.py +0 -0
  20. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/fasthtml/js.py +0 -0
  21. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/fasthtml/jupyter.py +0 -0
  22. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/fasthtml/katex.js +0 -0
  23. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/fasthtml/live_reload.py +0 -0
  24. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/fasthtml/oauth.py +0 -0
  25. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/fasthtml/pico.py +0 -0
  26. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/fasthtml/starlette.py +0 -0
  27. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/fasthtml/stripe_otp.py +0 -0
  28. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/fasthtml/svg.py +0 -0
  29. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/fasthtml/toaster.py +0 -0
  30. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/fasthtml/xtend.pyi +0 -0
  31. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/pyproject.toml +0 -0
  32. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/python_fasthtml.egg-info/SOURCES.txt +0 -0
  33. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/python_fasthtml.egg-info/dependency_links.txt +0 -0
  34. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/python_fasthtml.egg-info/entry_points.txt +0 -0
  35. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/python_fasthtml.egg-info/requires.txt +0 -0
  36. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/python_fasthtml.egg-info/top_level.txt +0 -0
  37. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/setup.cfg +0 -0
  38. {python_fasthtml-0.14.14 → python_fasthtml-0.14.16}/tests/test_toaster.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-fasthtml
3
- Version: 0.14.14
3
+ Version: 0.14.16
4
4
  Summary: The fastest way to create an HTML app
5
5
  Author-email: Jeremy Howard and contributors <github@jhoward.fastmail.fm>
6
6
  License-Expression: Apache-2.0
@@ -4,5 +4,5 @@ Modules:
4
4
 
5
5
  - `fasthtml.core`: The `FastHTML` subclass of `Starlette`."""
6
6
 
7
- __version__ = "0.14.14"
7
+ __version__ = "0.14.16"
8
8
  from .core import *
@@ -115,6 +115,7 @@ d = { 'settings': { 'branch': 'main',
115
115
  'fasthtml.core._form_arg': ('api/core.html#_form_arg', 'fasthtml/core.py'),
116
116
  'fasthtml.core._formitem': ('api/core.html#_formitem', 'fasthtml/core.py'),
117
117
  'fasthtml.core._from_body': ('api/core.html#_from_body', 'fasthtml/core.py'),
118
+ 'fasthtml.core._get_header': ('api/core.html#_get_header', 'fasthtml/core.py'),
118
119
  'fasthtml.core._get_htmx': ('api/core.html#_get_htmx', 'fasthtml/core.py'),
119
120
  'fasthtml.core._handle': ('api/core.html#_handle', 'fasthtml/core.py'),
120
121
  'fasthtml.core._is_body': ('api/core.html#_is_body', 'fasthtml/core.py'),
@@ -119,8 +119,14 @@ class HtmxHeaders:
119
119
  trigger_name:str|None=None; trigger:str|None=None
120
120
  def __bool__(self): return any(hasattr(self,o) for o in htmx_hdrs)
121
121
 
122
+ def _get_header(h, k):
123
+ k = k.lower()
124
+ res = h.get(k)
125
+ encoded = h.get(k+'-uri-autoencoded')=='true' or (k=='hx-prompt' and h.get('hx-request-type'))
126
+ return unquote(res) if res is not None and encoded else res
127
+
122
128
  def _get_htmx(h):
123
- res = {k:h.get(v.lower(), None) for k,v in htmx_hdrs.items()}
129
+ res = {k:_get_header(h, v) for k,v in htmx_hdrs.items()}
124
130
  return HtmxHeaders(**res)
125
131
 
126
132
  # %% ../nbs/api/00_core.ipynb #1d53e8e7
@@ -293,7 +299,7 @@ async def _find_p(conn, data, hdrs, arg:str, p:Parameter):
293
299
  # Not a special name or a special annotation
294
300
  res = conn.path_params.get(arg, None)
295
301
  if res in (empty,None): res = conn.cookies.get(arg, None)
296
- if res in (empty,None): res = hdrs.get(snake2hyphens(arg), None)
302
+ if res in (empty,None): res = _get_header(hdrs, snake2hyphens(arg))
297
303
  if res in (empty,None): res = _formitem(conn.query_params, arg)
298
304
  if res in (empty,None): res = _formitem(data, arg)
299
305
  if res in (empty,None) and isinstance(vals := data.get('values'), dict): res = _formitem(vals, arg) # htmx v4 nests form data under `values`
@@ -573,7 +579,7 @@ htmx_exts = {
573
579
  # %% ../nbs/api/00_core.ipynb #60cb52ea
574
580
  htmxsrc = Script(src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.7/dist/htmx.js")
575
581
  htmx4src = Script(src="https://cdn.jsdelivr.net/npm/htmx.org@4.0.0/dist/htmx.min.js")
576
- fhjsscr = Script(src="https://cdn.jsdelivr.net/gh/answerdotai/fasthtml-js@1.0.12/fasthtml.js")
582
+ fhjsscr = Script(src="https://cdn.jsdelivr.net/gh/answerdotai/fasthtml-js@1.0.13/fasthtml.js")
577
583
  surrsrc = Script(src="https://cdn.jsdelivr.net/gh/answerdotai/surreal@main/surreal.js")
578
584
  scopesrc = Script(src="https://cdn.jsdelivr.net/gh/gnat/css-scope-inline@main/script.js")
579
585
  viewport = Meta(name="viewport", content="width=device-width, initial-scale=1, viewport-fit=cover")
@@ -1155,8 +1161,8 @@ def _add_ids(s):
1155
1161
  @patch
1156
1162
  def setup_ws(app:FastHTML, f=noop):
1157
1163
  conns = {}
1158
- async def on_connect(scope, send): conns[scope.client] = send
1159
- async def on_disconnect(scope): conns.pop(scope.client)
1164
+ async def on_connect(ws, send): conns[ws.client] = send
1165
+ async def on_disconnect(ws): conns.pop(ws.client)
1160
1166
  app.ws('/ws', conn=on_connect, disconn=on_disconnect)(f)
1161
1167
  async def send(s):
1162
1168
  for o in conns.values(): await o(s)
@@ -249,7 +249,7 @@ async def _wrap_call(f, req, params):
249
249
  ...
250
250
  htmx_exts = {'morph': 'https://cdn.jsdelivr.net/npm/idiomorph@0.7.3/dist/idiomorph-ext.min.js', 'head-support': 'https://cdn.jsdelivr.net/npm/htmx-ext-head-support@2.0.4/head-support.js', 'preload': 'https://cdn.jsdelivr.net/npm/htmx-ext-preload@2.1.1/preload.js', 'class-tools': 'https://cdn.jsdelivr.net/npm/htmx-ext-class-tools@2.0.1/class-tools.js', 'loading-states': 'https://cdn.jsdelivr.net/npm/htmx-ext-loading-states@2.0.1/loading-states.js', 'multi-swap': 'https://cdn.jsdelivr.net/npm/htmx-ext-multi-swap@2.0.0/multi-swap.js', 'path-deps': 'https://cdn.jsdelivr.net/npm/htmx-ext-path-deps@2.0.0/path-deps.js', 'remove-me': 'https://cdn.jsdelivr.net/npm/htmx-ext-remove-me@2.0.0/remove-me.js', 'debug': 'https://unpkg.com/htmx.org@1.9.12/dist/ext/debug.js', 'ws': 'https://cdn.jsdelivr.net/npm/htmx-ext-ws@2.0.3/ws.js', 'chunked-transfer': 'https://cdn.jsdelivr.net/npm/htmx-ext-transfer-encoding-chunked@0.4.0/transfer-encoding-chunked.js'}
251
251
  htmxsrc = Script(src='https://cdn.jsdelivr.net/npm/htmx.org@2.0.7/dist/htmx.js')
252
- fhjsscr = Script(src='https://cdn.jsdelivr.net/gh/answerdotai/fasthtml-js@1.0.12/fasthtml.js')
252
+ fhjsscr = Script(src='https://cdn.jsdelivr.net/gh/answerdotai/fasthtml-js@1.0.13/fasthtml.js')
253
253
  surrsrc = Script(src='https://cdn.jsdelivr.net/gh/answerdotai/surreal@main/surreal.js')
254
254
  scopesrc = Script(src='https://cdn.jsdelivr.net/gh/gnat/css-scope-inline@main/script.js')
255
255
  viewport = Meta(name='viewport', content='width=device-width, initial-scale=1, viewport-fit=cover')
@@ -353,8 +353,9 @@ def sitemap_xml(app, urls, loc_base=""):
353
353
  return Urlset(*urlset, xmlns="http://www.sitemaps.org/schemas/sitemap/0.9")
354
354
 
355
355
  # %% ../nbs/api/02_xtend.ipynb #6a1990ed
356
- def upload_pb_attrs(id='uploadprog'):
357
- "Form `hx_on` progress attr that reveals and updates a hidden `upload_pb` of matching `id`"
356
+ def upload_pb_attrs(id='uploadprog', htmx4=False):
357
+ "Form attrs for an upload progress bar (htmx2) or request indicator (htmx4)"
358
+ if htmx4: return {'hx-indicator': f'#{id}'}
358
359
  js = """{ const p=document.getElementById('%s');
359
360
  if(event.detail.total) {p.classList.remove('hidden'); p.value=event.detail.loaded/event.detail.total*100} }""" % id
360
361
  return {'hx-on::xhr:progress': js}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-fasthtml
3
- Version: 0.14.14
3
+ Version: 0.14.16
4
4
  Summary: The fastest way to create an HTML app
5
5
  Author-email: Jeremy Howard and contributors <github@jhoward.fastmail.fm>
6
6
  License-Expression: Apache-2.0