python-fasthtml 0.12.31__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.
Files changed (42) hide show
  1. {python_fasthtml-0.12.31/python_fasthtml.egg-info → python_fasthtml-0.12.32}/PKG-INFO +1 -1
  2. python_fasthtml-0.12.32/fasthtml/__init__.py +2 -0
  3. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/fasthtml/core.py +7 -3
  4. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/fasthtml/jupyter.py +13 -7
  5. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32/python_fasthtml.egg-info}/PKG-INFO +1 -1
  6. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/settings.ini +1 -1
  7. python_fasthtml-0.12.31/fasthtml/__init__.py +0 -2
  8. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/CONTRIBUTING.md +0 -0
  9. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/LICENSE +0 -0
  10. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/MANIFEST.in +0 -0
  11. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/README.md +0 -0
  12. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/fasthtml/_modidx.py +0 -0
  13. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/fasthtml/authmw.py +0 -0
  14. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/fasthtml/basics.py +0 -0
  15. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/fasthtml/cli.py +0 -0
  16. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/fasthtml/common.py +0 -0
  17. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/fasthtml/components.py +0 -0
  18. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/fasthtml/components.pyi +0 -0
  19. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/fasthtml/core.pyi +0 -0
  20. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/fasthtml/fastapp.py +0 -0
  21. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/fasthtml/ft.py +0 -0
  22. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/fasthtml/js.py +0 -0
  23. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/fasthtml/katex.js +0 -0
  24. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/fasthtml/live_reload.py +0 -0
  25. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/fasthtml/oauth.py +0 -0
  26. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/fasthtml/pico.py +0 -0
  27. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/fasthtml/starlette.py +0 -0
  28. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/fasthtml/stripe_otp.py +0 -0
  29. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/fasthtml/svg.py +0 -0
  30. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/fasthtml/toaster.py +0 -0
  31. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/fasthtml/xtend.py +0 -0
  32. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/fasthtml/xtend.pyi +0 -0
  33. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/pyproject.toml +0 -0
  34. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/python_fasthtml.egg-info/SOURCES.txt +0 -0
  35. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/python_fasthtml.egg-info/dependency_links.txt +0 -0
  36. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/python_fasthtml.egg-info/entry_points.txt +0 -0
  37. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/python_fasthtml.egg-info/not-zip-safe +0 -0
  38. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/python_fasthtml.egg-info/requires.txt +0 -0
  39. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/python_fasthtml.egg-info/top_level.txt +0 -0
  40. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/setup.cfg +0 -0
  41. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/setup.py +0 -0
  42. {python_fasthtml-0.12.31 → python_fasthtml-0.12.32}/tests/test_toaster.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-fasthtml
3
- Version: 0.12.31
3
+ Version: 0.12.32
4
4
  Summary: The fastest way to create an HTML app
5
5
  Home-page: https://github.com/AnswerDotAI/fasthtml
6
6
  Author: Jeremy Howard and contributors
@@ -0,0 +1,2 @@
1
+ __version__ = "0.12.32"
2
+ from .core import *
@@ -650,13 +650,17 @@ def ws(self:FastHTML, path:str, conn=None, disconn=None, name=None, middleware=N
650
650
  return f
651
651
 
652
652
  # %% ../nbs/api/00_core.ipynb
653
- def _mk_locfunc(f,p):
653
+ def _mk_locfunc(f, p, app=None):
654
654
  "Create a location function wrapper with route path and to() method"
655
655
  class _lf:
656
- def __init__(self): update_wrapper(self, f)
656
+ def __init__(self):
657
+ update_wrapper(self, f)
658
+ self.app = app
659
+
657
660
  def __call__(self, *args, **kw): return f(*args, **kw)
658
661
  def to(self, **kw): return qp(p, **kw)
659
662
  def __str__(self): return p
663
+
660
664
  return _lf()
661
665
 
662
666
  # %% ../nbs/api/00_core.ipynb
@@ -676,7 +680,7 @@ def _add_route(self:FastHTML, func, path, methods, name, include_in_schema, body
676
680
  if not p: p = '/'+('' if fn=='index' else fn)
677
681
  route = Route(p, endpoint=self._endp(func, body_wrap or self.body_wrap), methods=m, name=n, include_in_schema=include_in_schema)
678
682
  self.add_route(route)
679
- lf = _mk_locfunc(func, p)
683
+ lf = _mk_locfunc(func, p, app=self)
680
684
  lf.__routename__ = n
681
685
  return lf
682
686
 
@@ -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="{fullpath}" 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> """)
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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-fasthtml
3
- Version: 0.12.31
3
+ Version: 0.12.32
4
4
  Summary: The fastest way to create an HTML app
5
5
  Home-page: https://github.com/AnswerDotAI/fasthtml
6
6
  Author: Jeremy Howard and contributors
@@ -1,7 +1,7 @@
1
1
  [DEFAULT]
2
2
  repo = fasthtml
3
3
  lib_name = python-fasthtml
4
- version = 0.12.31
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
@@ -1,2 +0,0 @@
1
- __version__ = "0.12.31"
2
- from .core import *