python-fasthtml 0.14.4__tar.gz → 0.14.5__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 (39) hide show
  1. {python_fasthtml-0.14.4/python_fasthtml.egg-info → python_fasthtml-0.14.5}/PKG-INFO +2 -2
  2. python_fasthtml-0.14.5/fasthtml/__init__.py +2 -0
  3. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/fasthtml/_modidx.py +3 -1
  4. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/fasthtml/components.py +2 -6
  5. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/fasthtml/core.py +34 -4
  6. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/fasthtml/js.py +1 -1
  7. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/fasthtml/jupyter.py +1 -1
  8. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/fasthtml/oauth.py +1 -1
  9. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/fasthtml/pico.py +1 -1
  10. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/fasthtml/stripe_otp.py +1 -1
  11. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/fasthtml/svg.py +1 -1
  12. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/fasthtml/xtend.py +1 -1
  13. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/pyproject.toml +4 -1
  14. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5/python_fasthtml.egg-info}/PKG-INFO +2 -2
  15. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/python_fasthtml.egg-info/requires.txt +1 -1
  16. python_fasthtml-0.14.4/fasthtml/__init__.py +0 -2
  17. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/CONTRIBUTING.md +0 -0
  18. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/LICENSE +0 -0
  19. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/MANIFEST.in +0 -0
  20. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/README.md +0 -0
  21. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/fasthtml/authmw.py +0 -0
  22. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/fasthtml/basics.py +0 -0
  23. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/fasthtml/cli.py +0 -0
  24. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/fasthtml/common.py +0 -0
  25. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/fasthtml/components.pyi +0 -0
  26. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/fasthtml/core.pyi +0 -0
  27. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/fasthtml/fastapp.py +0 -0
  28. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/fasthtml/ft.py +0 -0
  29. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/fasthtml/katex.js +0 -0
  30. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/fasthtml/live_reload.py +0 -0
  31. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/fasthtml/starlette.py +0 -0
  32. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/fasthtml/toaster.py +0 -0
  33. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/fasthtml/xtend.pyi +0 -0
  34. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/python_fasthtml.egg-info/SOURCES.txt +0 -0
  35. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/python_fasthtml.egg-info/dependency_links.txt +0 -0
  36. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/python_fasthtml.egg-info/entry_points.txt +0 -0
  37. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/python_fasthtml.egg-info/top_level.txt +0 -0
  38. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/setup.cfg +0 -0
  39. {python_fasthtml-0.14.4 → python_fasthtml-0.14.5}/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.4
3
+ Version: 0.14.5
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: Apache-2.0
@@ -15,7 +15,7 @@ Classifier: Programming Language :: Python :: 3 :: Only
15
15
  Requires-Python: >=3.10
16
16
  Description-Content-Type: text/markdown
17
17
  License-File: LICENSE
18
- Requires-Dist: fastcore>=1.12.45
18
+ Requires-Dist: fastcore>=1.14.2
19
19
  Requires-Dist: python-dateutil
20
20
  Requires-Dist: starlette>=1.0.1
21
21
  Requires-Dist: oauthlib
@@ -0,0 +1,2 @@
1
+ __version__ = "0.14.5"
2
+ from .core import *
@@ -15,7 +15,6 @@ d = { 'settings': { 'branch': 'main',
15
15
  'fasthtml.components.FT.__radd__': ('api/components.html#ft.__radd__', 'fasthtml/components.py'),
16
16
  'fasthtml.components.FT.__str__': ('api/components.html#ft.__str__', 'fasthtml/components.py'),
17
17
  'fasthtml.components.File': ('api/components.html#file', 'fasthtml/components.py'),
18
- 'fasthtml.components.__getattr__': ('api/components.html#__getattr__', 'fasthtml/components.py'),
19
18
  'fasthtml.components._fill_item': ('api/components.html#_fill_item', 'fasthtml/components.py'),
20
19
  'fasthtml.components.attrmap_x': ('api/components.html#attrmap_x', 'fasthtml/components.py'),
21
20
  'fasthtml.components.fill_dataclass': ('api/components.html#fill_dataclass', 'fasthtml/components.py'),
@@ -131,6 +130,7 @@ d = { 'settings': { 'branch': 'main',
131
130
  'fasthtml.core._to_htmx_header': ('api/core.html#_to_htmx_header', 'fasthtml/core.py'),
132
131
  'fasthtml.core._to_xml': ('api/core.html#_to_xml', 'fasthtml/core.py'),
133
132
  'fasthtml.core._url_for': ('api/core.html#_url_for', 'fasthtml/core.py'),
133
+ 'fasthtml.core._wait_disconnect': ('api/core.html#_wait_disconnect', 'fasthtml/core.py'),
134
134
  'fasthtml.core._wrap_call': ('api/core.html#_wrap_call', 'fasthtml/core.py'),
135
135
  'fasthtml.core._wrap_ex': ('api/core.html#_wrap_ex', 'fasthtml/core.py'),
136
136
  'fasthtml.core._wrap_req': ('api/core.html#_wrap_req', 'fasthtml/core.py'),
@@ -138,6 +138,7 @@ d = { 'settings': { 'branch': 'main',
138
138
  'fasthtml.core._ws_endp': ('api/core.html#_ws_endp', 'fasthtml/core.py'),
139
139
  'fasthtml.core._xt_cts': ('api/core.html#_xt_cts', 'fasthtml/core.py'),
140
140
  'fasthtml.core.add_sig_param': ('api/core.html#add_sig_param', 'fasthtml/core.py'),
141
+ 'fasthtml.core.cancel_on_disconnect': ('api/core.html#cancel_on_disconnect', 'fasthtml/core.py'),
141
142
  'fasthtml.core.cookie': ('api/core.html#cookie', 'fasthtml/core.py'),
142
143
  'fasthtml.core.decode_uri': ('api/core.html#decode_uri', 'fasthtml/core.py'),
143
144
  'fasthtml.core.def_hdrs': ('api/core.html#def_hdrs', 'fasthtml/core.py'),
@@ -160,6 +161,7 @@ d = { 'settings': { 'branch': 'main',
160
161
  'fasthtml.core.signal_shutdown': ('api/core.html#signal_shutdown', 'fasthtml/core.py'),
161
162
  'fasthtml.core.snake2hyphens': ('api/core.html#snake2hyphens', 'fasthtml/core.py'),
162
163
  'fasthtml.core.unqid': ('api/core.html#unqid', 'fasthtml/core.py'),
164
+ 'fasthtml.core.until_disconnect': ('api/core.html#until_disconnect', 'fasthtml/core.py'),
163
165
  'fasthtml.core.uri': ('api/core.html#uri', 'fasthtml/core.py')},
164
166
  'fasthtml.fastapp': {},
165
167
  'fasthtml.ft': {},
@@ -1,6 +1,6 @@
1
1
  """`ft_html` and `ft_hx` functions to add some conveniences to `ft`, along with a full set of basic HTML components, and functions to work with forms and `FT` conversion
2
2
 
3
- Docs: https://www.fastht.ml/docsapi/components.html.md"""
3
+ Docs: https://www.fastht.ml/docs/api/components.html.md"""
4
4
 
5
5
  # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/api/01_components.ipynb.
6
6
 
@@ -195,11 +195,7 @@ def find_inputs(e, tags='input', **kw):
195
195
  return inputs
196
196
 
197
197
  # %% ../nbs/api/01_components.ipynb #1d8a28b1
198
- def __getattr__(tag):
199
- if tag.startswith('_') or tag[0].islower(): raise AttributeError
200
- tag = tag.replace("_", "-")
201
- def _f(*c, target_id=None, **kwargs): return ft_hx(tag, *c, target_id=target_id, **kwargs)
202
- return _f
198
+ __getattr__ = mk_getattr(ft_hx)
203
199
 
204
200
  # %% ../nbs/api/01_components.ipynb #afb0f65c
205
201
  _re_h2x_attr_key = re.compile(r'^[A-Za-z_-][\w-]*$')
@@ -1,6 +1,6 @@
1
1
  """The `FastHTML` subclass of `Starlette`.
2
2
 
3
- Docs: https://www.fastht.ml/docsapi/core.html.md"""
3
+ Docs: https://www.fastht.ml/docs/api/core.html.md"""
4
4
 
5
5
  # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/api/00_core.ipynb.
6
6
 
@@ -10,15 +10,16 @@ __all__ = ['empty', 'htmx_hdrs', 'fh_cfg', 'htmx_resps', 'DEF_MAXPART', 'htmx_ex
10
10
  'snake2hyphens', 'HtmxHeaders', 'HttpHeader', 'HtmxResponseHeaders', 'form2dict', 'parse_form', 'ApiReturn',
11
11
  'JSONResponse', 'flat_xt', 'Beforeware', 'EventStream', 'signal_shutdown', 'uri', 'decode_uri', 'flat_tuple',
12
12
  'noop_body', 'respond', 'is_full_page', 'Redirect', 'get_key', 'qp', 'def_hdrs', 'Lifespan', 'FastHTML',
13
- 'HostRoute', 'nested_name', 'serve', 'Client', 'RouteFuncs', 'APIRouter', 'cookie', 'reg_re_param',
14
- 'StaticNoCache', 'add_sig_param', 'into', 'MiddlewareBase', 'FtResponse', 'unqid']
13
+ 'HostRoute', 'nested_name', 'serve', 'until_disconnect', 'cancel_on_disconnect', 'Client', 'RouteFuncs',
14
+ 'APIRouter', 'cookie', 'reg_re_param', 'StaticNoCache', 'add_sig_param', 'into', 'MiddlewareBase',
15
+ 'FtResponse', 'unqid']
15
16
 
16
17
  # %% ../nbs/api/00_core.ipynb #23503b9e
17
18
  import json,uuid,inspect,types,asyncio,inspect,random,contextlib,itsdangerous
18
19
 
19
20
  from fastcore.utils import *
20
21
  from fastcore.xml import *
21
- from fastcore.meta import use_kwargs_dict,delegates
22
+ from fastcore.meta import use_kwargs_dict,delegates,splice_sig
22
23
  from fastcore.style import S
23
24
 
24
25
  from types import UnionType, SimpleNamespace as ns, GenericAlias
@@ -819,6 +820,35 @@ def serve(
819
820
  print('Link: '+ S.light_red.bold(link))
820
821
  run(f'{appname}:{app}', host=host, port=port, reload=reload, **kwargs)
821
822
 
823
+ # %% ../nbs/api/00_core.ipynb #c5220a0e
824
+ async def _wait_disconnect(req):
825
+ while (await req.receive())["type"] != "http.disconnect": pass
826
+
827
+ async def until_disconnect(req, coro):
828
+ "Await `coro`, cancelling it (and returning an empty response) if the client disconnects first"
829
+ work,watch = asyncio.ensure_future(coro),asyncio.ensure_future(_wait_disconnect(req))
830
+ try:
831
+ done,_ = await asyncio.wait({work,watch}, return_when=asyncio.FIRST_COMPLETED)
832
+ if work in done: return work.result()
833
+ return Response(status_code=204)
834
+ finally:
835
+ watch.cancel()
836
+ if not work.done(): work.cancel()
837
+
838
+ # %% ../nbs/api/00_core.ipynb #c5721d76
839
+ def cancel_on_disconnect(
840
+ f=None, # Async route handler to wrap
841
+ *,
842
+ timeout=None, # Also cancel the handler after this many seconds
843
+ ):
844
+ "Route decorator: cancel the handler when the client disconnects"
845
+ if f is None: return partial(cancel_on_disconnect, timeout=timeout)
846
+ assert is_async_callable(f), "cancel_on_disconnect requires an async handler"
847
+ async def _f(__req: Request, *args, **kw):
848
+ c = until_disconnect(__req, f(**kw))
849
+ return await (asyncio.wait_for(c, timeout) if timeout is not None else c)
850
+ return splice_sig(_f, f)
851
+
822
852
  # %% ../nbs/api/00_core.ipynb #8121968a
823
853
  class Client:
824
854
  "A simple httpx ASGI client that doesn't require `async`"
@@ -1,6 +1,6 @@
1
1
  """Basic external Javascript lib wrappers
2
2
 
3
- Docs: https://www.fastht.ml/docsapi/js.html.md"""
3
+ Docs: https://www.fastht.ml/docs/api/js.html.md"""
4
4
 
5
5
  # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/api/03_js.ipynb.
6
6
 
@@ -1,6 +1,6 @@
1
1
  """Use FastHTML in Jupyter notebooks
2
2
 
3
- Docs: https://www.fastht.ml/docsapi/jupyter.html.md"""
3
+ Docs: https://www.fastht.ml/docs/api/jupyter.html.md"""
4
4
 
5
5
  # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/api/06_jupyter.ipynb.
6
6
 
@@ -1,6 +1,6 @@
1
1
  """Basic scaffolding for handling OAuth
2
2
 
3
- Docs: https://www.fastht.ml/docsapi/oauth.html.md"""
3
+ Docs: https://www.fastht.ml/docs/api/oauth.html.md"""
4
4
 
5
5
  # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/api/08_oauth.ipynb.
6
6
 
@@ -1,6 +1,6 @@
1
1
  """Basic components for generating Pico CSS tags
2
2
 
3
- Docs: https://www.fastht.ml/docsapi/pico.html.md"""
3
+ Docs: https://www.fastht.ml/docs/api/pico.html.md"""
4
4
 
5
5
  # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/api/04_pico.ipynb.
6
6
 
@@ -1,4 +1,4 @@
1
- """Docs: https://www.fastht.ml/docsexplains/stripe.html.md"""
1
+ """Docs: https://www.fastht.ml/docs/explains/stripe.html.md"""
2
2
 
3
3
  # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/explains/Stripe.ipynb.
4
4
 
@@ -1,6 +1,6 @@
1
1
  """Simple SVG FT elements
2
2
 
3
- Docs: https://www.fastht.ml/docsapi/svg.html.md"""
3
+ Docs: https://www.fastht.ml/docs/api/svg.html.md"""
4
4
 
5
5
  # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/api/05_svg.ipynb.
6
6
 
@@ -1,6 +1,6 @@
1
1
  """Simple extensions to standard HTML components, such as adding sensible defaults
2
2
 
3
- Docs: https://www.fastht.ml/docsapi/xtend.html.md"""
3
+ Docs: https://www.fastht.ml/docs/api/xtend.html.md"""
4
4
 
5
5
  # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/api/02_xtend.ipynb.
6
6
 
@@ -12,7 +12,7 @@ license = {text = "Apache-2.0"}
12
12
  authors = [{name = "Jeremy Howard and contributors", email = "github@jhoward.fastmail.fm"}]
13
13
  keywords = ['nbdev', 'jupyter', 'notebook', 'python']
14
14
  classifiers = ["Natural Language :: English", "Intended Audience :: Developers", "Development Status :: 3 - Alpha", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only"]
15
- dependencies = ['fastcore>=1.12.45', 'python-dateutil', 'starlette>=1.0.1', 'oauthlib', 'itsdangerous', 'uvicorn[standard]>=0.30', 'httpx2', 'fastlite>=0.1.1', 'python-multipart', 'beautifulsoup4']
15
+ dependencies = ['fastcore>=1.14.2', 'python-dateutil', 'starlette>=1.0.1', 'oauthlib', 'itsdangerous', 'uvicorn[standard]>=0.30', 'httpx2', 'fastlite>=0.1.1', 'python-multipart', 'beautifulsoup4']
16
16
 
17
17
  [project.urls]
18
18
  Repository = "https://github.com/AnswerDotAI/fasthtml"
@@ -41,3 +41,6 @@ allowed_cell_metadata_keys = ['solveit_ai']
41
41
  jupyter_hooks = true
42
42
  custom_sidebar = false
43
43
  lib_path = "fasthtml"
44
+
45
+ [tool.chkstyle]
46
+ skip_paths = ["_modidx.py"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-fasthtml
3
- Version: 0.14.4
3
+ Version: 0.14.5
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: Apache-2.0
@@ -15,7 +15,7 @@ Classifier: Programming Language :: Python :: 3 :: Only
15
15
  Requires-Python: >=3.10
16
16
  Description-Content-Type: text/markdown
17
17
  License-File: LICENSE
18
- Requires-Dist: fastcore>=1.12.45
18
+ Requires-Dist: fastcore>=1.14.2
19
19
  Requires-Dist: python-dateutil
20
20
  Requires-Dist: starlette>=1.0.1
21
21
  Requires-Dist: oauthlib
@@ -1,4 +1,4 @@
1
- fastcore>=1.12.45
1
+ fastcore>=1.14.2
2
2
  python-dateutil
3
3
  starlette>=1.0.1
4
4
  oauthlib
@@ -1,2 +0,0 @@
1
- __version__ = "0.14.4"
2
- from .core import *