python-fasthtml 0.14.15__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.15/python_fasthtml.egg-info → python_fasthtml-0.14.16}/PKG-INFO +1 -1
  2. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/fasthtml/__init__.py +1 -1
  3. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/fasthtml/_modidx.py +1 -0
  4. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/fasthtml/core.py +8 -2
  5. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/fasthtml/xtend.py +3 -2
  6. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16/python_fasthtml.egg-info}/PKG-INFO +1 -1
  7. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/CONTRIBUTING.md +0 -0
  8. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/LICENSE +0 -0
  9. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/MANIFEST.in +0 -0
  10. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/README.md +0 -0
  11. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/fasthtml/authmw.py +0 -0
  12. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/fasthtml/basics.py +0 -0
  13. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/fasthtml/cli.py +0 -0
  14. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/fasthtml/common.py +0 -0
  15. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/fasthtml/components.py +0 -0
  16. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/fasthtml/components.pyi +0 -0
  17. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/fasthtml/core.pyi +0 -0
  18. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/fasthtml/fastapp.py +0 -0
  19. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/fasthtml/ft.py +0 -0
  20. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/fasthtml/js.py +0 -0
  21. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/fasthtml/jupyter.py +0 -0
  22. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/fasthtml/katex.js +0 -0
  23. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/fasthtml/live_reload.py +0 -0
  24. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/fasthtml/oauth.py +0 -0
  25. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/fasthtml/pico.py +0 -0
  26. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/fasthtml/starlette.py +0 -0
  27. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/fasthtml/stripe_otp.py +0 -0
  28. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/fasthtml/svg.py +0 -0
  29. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/fasthtml/toaster.py +0 -0
  30. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/fasthtml/xtend.pyi +0 -0
  31. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/pyproject.toml +0 -0
  32. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/python_fasthtml.egg-info/SOURCES.txt +0 -0
  33. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/python_fasthtml.egg-info/dependency_links.txt +0 -0
  34. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/python_fasthtml.egg-info/entry_points.txt +0 -0
  35. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/python_fasthtml.egg-info/requires.txt +0 -0
  36. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/python_fasthtml.egg-info/top_level.txt +0 -0
  37. {python_fasthtml-0.14.15 → python_fasthtml-0.14.16}/setup.cfg +0 -0
  38. {python_fasthtml-0.14.15 → 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.15
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.15"
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`
@@ -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.15
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