python-fasthtml 0.13.1__tar.gz → 0.13.3__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.13.1/python_fasthtml.egg-info → python_fasthtml-0.13.3}/PKG-INFO +1 -1
- python_fasthtml-0.13.3/fasthtml/__init__.py +2 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/fasthtml/_modidx.py +5 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/fasthtml/core.py +45 -4
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/pyproject.toml +2 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3/python_fasthtml.egg-info}/PKG-INFO +1 -1
- python_fasthtml-0.13.1/fasthtml/__init__.py +0 -2
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/CONTRIBUTING.md +0 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/LICENSE +0 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/MANIFEST.in +0 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/README.md +0 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/fasthtml/authmw.py +0 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/fasthtml/basics.py +0 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/fasthtml/cli.py +0 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/fasthtml/common.py +0 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/fasthtml/components.py +0 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/fasthtml/components.pyi +0 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/fasthtml/core.pyi +0 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/fasthtml/fastapp.py +0 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/fasthtml/ft.py +0 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/fasthtml/js.py +0 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/fasthtml/jupyter.py +0 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/fasthtml/katex.js +0 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/fasthtml/live_reload.py +0 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/fasthtml/oauth.py +0 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/fasthtml/pico.py +0 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/fasthtml/starlette.py +0 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/fasthtml/stripe_otp.py +0 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/fasthtml/svg.py +0 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/fasthtml/toaster.py +0 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/fasthtml/xtend.py +0 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/fasthtml/xtend.pyi +0 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/python_fasthtml.egg-info/SOURCES.txt +0 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/python_fasthtml.egg-info/dependency_links.txt +0 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/python_fasthtml.egg-info/entry_points.txt +0 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/python_fasthtml.egg-info/requires.txt +0 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/python_fasthtml.egg-info/top_level.txt +0 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/setup.cfg +0 -0
- {python_fasthtml-0.13.1 → python_fasthtml-0.13.3}/tests/test_toaster.py +0 -0
|
@@ -40,6 +40,7 @@ d = { 'settings': { 'branch': 'main',
|
|
|
40
40
|
'fasthtml.core.ApiReturn.__init__': ('api/core.html#apireturn.__init__', 'fasthtml/core.py'),
|
|
41
41
|
'fasthtml.core.Beforeware': ('api/core.html#beforeware', 'fasthtml/core.py'),
|
|
42
42
|
'fasthtml.core.Beforeware.__init__': ('api/core.html#beforeware.__init__', 'fasthtml/core.py'),
|
|
43
|
+
'fasthtml.core.Beforeware.__repr__': ('api/core.html#beforeware.__repr__', 'fasthtml/core.py'),
|
|
43
44
|
'fasthtml.core.Client': ('api/core.html#client', 'fasthtml/core.py'),
|
|
44
45
|
'fasthtml.core.Client.__init__': ('api/core.html#client.__init__', 'fasthtml/core.py'),
|
|
45
46
|
'fasthtml.core.Client._sync': ('api/core.html#client._sync', 'fasthtml/core.py'),
|
|
@@ -133,6 +134,7 @@ d = { 'settings': { 'branch': 'main',
|
|
|
133
134
|
'fasthtml.core._wrap_ws': ('api/core.html#_wrap_ws', 'fasthtml/core.py'),
|
|
134
135
|
'fasthtml.core._ws_endp': ('api/core.html#_ws_endp', 'fasthtml/core.py'),
|
|
135
136
|
'fasthtml.core._xt_cts': ('api/core.html#_xt_cts', 'fasthtml/core.py'),
|
|
137
|
+
'fasthtml.core.add_sig_param': ('api/core.html#add_sig_param', 'fasthtml/core.py'),
|
|
136
138
|
'fasthtml.core.cookie': ('api/core.html#cookie', 'fasthtml/core.py'),
|
|
137
139
|
'fasthtml.core.decode_uri': ('api/core.html#decode_uri', 'fasthtml/core.py'),
|
|
138
140
|
'fasthtml.core.def_hdrs': ('api/core.html#def_hdrs', 'fasthtml/core.py'),
|
|
@@ -140,6 +142,9 @@ d = { 'settings': { 'branch': 'main',
|
|
|
140
142
|
'fasthtml.core.flat_xt': ('api/core.html#flat_xt', 'fasthtml/core.py'),
|
|
141
143
|
'fasthtml.core.form2dict': ('api/core.html#form2dict', 'fasthtml/core.py'),
|
|
142
144
|
'fasthtml.core.get_key': ('api/core.html#get_key', 'fasthtml/core.py'),
|
|
145
|
+
'fasthtml.core.into': ('api/core.html#into', 'fasthtml/core.py'),
|
|
146
|
+
'fasthtml.core.into.__call__': ('api/core.html#into.__call__', 'fasthtml/core.py'),
|
|
147
|
+
'fasthtml.core.into.__init__': ('api/core.html#into.__init__', 'fasthtml/core.py'),
|
|
143
148
|
'fasthtml.core.is_full_page': ('api/core.html#is_full_page', 'fasthtml/core.py'),
|
|
144
149
|
'fasthtml.core.nested_name': ('api/core.html#nested_name', 'fasthtml/core.py'),
|
|
145
150
|
'fasthtml.core.noop_body': ('api/core.html#noop_body', 'fasthtml/core.py'),
|
|
@@ -9,7 +9,7 @@ __all__ = ['empty', 'htmx_hdrs', 'fh_cfg', 'htmx_resps', 'htmx_exts', 'htmxsrc',
|
|
|
9
9
|
'flat_xt', 'Beforeware', 'EventStream', 'signal_shutdown', 'uri', 'decode_uri', 'flat_tuple', 'noop_body',
|
|
10
10
|
'respond', 'is_full_page', 'Redirect', 'get_key', 'qp', 'def_hdrs', 'Lifespan', 'FastHTML', 'HostRoute',
|
|
11
11
|
'nested_name', 'serve', 'Client', 'RouteFuncs', 'APIRouter', 'cookie', 'reg_re_param', 'StaticNoCache',
|
|
12
|
-
'MiddlewareBase', 'FtResponse', 'unqid']
|
|
12
|
+
'add_sig_param', 'into', 'MiddlewareBase', 'FtResponse', 'unqid']
|
|
13
13
|
|
|
14
14
|
# %% ../nbs/api/00_core.ipynb #23503b9e
|
|
15
15
|
import json,uuid,inspect,types,asyncio,inspect,random,contextlib,httpx,itsdangerous,uvicorn
|
|
@@ -163,12 +163,15 @@ async def parse_form(req: Request) -> FormData:
|
|
|
163
163
|
return await req.json() if ctype == 'application/json' else await req.form()
|
|
164
164
|
|
|
165
165
|
|
|
166
|
-
# %% ../nbs/api/00_core.ipynb #
|
|
166
|
+
# %% ../nbs/api/00_core.ipynb #0caedd04
|
|
167
167
|
async def _from_body(conn, p, data):
|
|
168
168
|
"Create an instance of the annotated type from pre-parsed `data`"
|
|
169
169
|
anno = p.annotation
|
|
170
170
|
ctor = getattr(anno, '__from_request__', None)
|
|
171
|
-
if ctor:
|
|
171
|
+
if ctor:
|
|
172
|
+
ps = {k:v for k,v in _params(ctor).items() if k != 'cls'}
|
|
173
|
+
kwargs = await _find_ps(conn, data, conn.headers, ps)
|
|
174
|
+
return await maybe_await(ctor(**kwargs))
|
|
172
175
|
d = _annotations(anno)
|
|
173
176
|
cargs = {k: _form_arg(k, v, d) for k, v in data.items() if not d or k in d}
|
|
174
177
|
return anno(**cargs)
|
|
@@ -260,6 +263,7 @@ def flat_xt(lst):
|
|
|
260
263
|
# %% ../nbs/api/00_core.ipynb #aacff5ac
|
|
261
264
|
class Beforeware:
|
|
262
265
|
def __init__(self, f, skip=None): self.f,self.skip = f,skip or []
|
|
266
|
+
def __repr__(self): return f'Beforeware({self.f}, skip={self.skip})'
|
|
263
267
|
|
|
264
268
|
# %% ../nbs/api/00_core.ipynb #78c3c357
|
|
265
269
|
async def _handle(f, *args, **kwargs):
|
|
@@ -267,7 +271,7 @@ async def _handle(f, *args, **kwargs):
|
|
|
267
271
|
|
|
268
272
|
# %% ../nbs/api/00_core.ipynb #ad0f0e87
|
|
269
273
|
async def _wrap_ws(ws, data, params):
|
|
270
|
-
hdrs = {k.lower()
|
|
274
|
+
hdrs = Headers({k.lower():v for k,v in data.pop('HEADERS', {}).items() if v is not None})
|
|
271
275
|
return await _find_ps(ws, data, hdrs, params)
|
|
272
276
|
|
|
273
277
|
# %% ../nbs/api/00_core.ipynb #dcc15129
|
|
@@ -904,6 +908,43 @@ class StaticNoCache(StaticFiles):
|
|
|
904
908
|
resp.headers.setdefault("Cache-Control", "no-cache")
|
|
905
909
|
return resp
|
|
906
910
|
|
|
911
|
+
# %% ../nbs/api/00_core.ipynb #7189daf8
|
|
912
|
+
from functools import wraps
|
|
913
|
+
from inspect import signature, isawaitable
|
|
914
|
+
|
|
915
|
+
# %% ../nbs/api/00_core.ipynb #7eed23b7
|
|
916
|
+
def add_sig_param(f, name, typ=NoneType, kind=Parameter.KEYWORD_ONLY, default=Parameter.empty):
|
|
917
|
+
"Add a parameter to a function's signature"
|
|
918
|
+
sig = signature(f)
|
|
919
|
+
if name in sig.parameters: return f
|
|
920
|
+
kw = {} if default is Parameter.empty else {'default': default}
|
|
921
|
+
new_params = list(sig.parameters.values()) + [Parameter(name, kind, **kw)]
|
|
922
|
+
f.__signature__ = sig.replace(parameters=new_params)
|
|
923
|
+
f.__annotations__[name] = typ
|
|
924
|
+
return f
|
|
925
|
+
|
|
926
|
+
# %% ../nbs/api/00_core.ipynb #9e5a9e88
|
|
927
|
+
class into:
|
|
928
|
+
"Decorator to pass a route's return value into `func`, with keyword params added to the route signature"
|
|
929
|
+
def __init__(self, func):
|
|
930
|
+
self.func = func
|
|
931
|
+
self.params = {k:p for k,p in signature(func).parameters.items()
|
|
932
|
+
if p.kind not in (Parameter.VAR_POSITIONAL, Parameter.VAR_KEYWORD)}
|
|
933
|
+
|
|
934
|
+
def __call__(self, f):
|
|
935
|
+
@wraps(f)
|
|
936
|
+
async def _inner(*args, **kw):
|
|
937
|
+
extra = {k: kw.pop(k, None) for k in self.params}
|
|
938
|
+
res = f(*args, **kw)
|
|
939
|
+
if isawaitable(res): res = await res
|
|
940
|
+
res = self.func(*tuplify(res), **extra)
|
|
941
|
+
if isawaitable(res): res = await res
|
|
942
|
+
return res
|
|
943
|
+
for k,p in self.params.items():
|
|
944
|
+
anno = p.annotation if p.annotation is not Parameter.empty else NoneType
|
|
945
|
+
add_sig_param(_inner, k, anno, default=p.default)
|
|
946
|
+
return _inner
|
|
947
|
+
|
|
907
948
|
# %% ../nbs/api/00_core.ipynb #1960d7ff
|
|
908
949
|
class MiddlewareBase:
|
|
909
950
|
async def __call__(self, scope, receive, send) -> None:
|
|
@@ -36,6 +36,8 @@ version = {attr = "fasthtml.__version__"}
|
|
|
36
36
|
include = ["fasthtml"]
|
|
37
37
|
|
|
38
38
|
[tool.nbdev]
|
|
39
|
+
allowed_metadata_keys = ['solveit_dialog_mode', 'solveit_ver']
|
|
40
|
+
allowed_cell_metadata_keys = ["solveit_ai"]
|
|
39
41
|
jupyter_hooks = true
|
|
40
42
|
custom_sidebar = false
|
|
41
43
|
lib_path = "fasthtml"
|
|
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.13.1 → python_fasthtml-0.13.3}/python_fasthtml.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|