python-fasthtml 0.3.0__tar.gz → 0.3.2__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.3.0/python_fasthtml.egg-info → python-fasthtml-0.3.2}/PKG-INFO +2 -2
- {python-fasthtml-0.3.0 → python-fasthtml-0.3.2}/fasthtml/__init__.py +1 -1
- {python-fasthtml-0.3.0 → python-fasthtml-0.3.2}/fasthtml/_modidx.py +1 -0
- {python-fasthtml-0.3.0 → python-fasthtml-0.3.2}/fasthtml/components.py +14 -6
- {python-fasthtml-0.3.0 → python-fasthtml-0.3.2}/fasthtml/core.py +8 -6
- {python-fasthtml-0.3.0 → python-fasthtml-0.3.2}/fasthtml/xtend.py +7 -2
- {python-fasthtml-0.3.0 → python-fasthtml-0.3.2/python_fasthtml.egg-info}/PKG-INFO +2 -2
- {python-fasthtml-0.3.0 → python-fasthtml-0.3.2}/python_fasthtml.egg-info/requires.txt +1 -1
- {python-fasthtml-0.3.0 → python-fasthtml-0.3.2}/settings.ini +2 -2
- {python-fasthtml-0.3.0 → python-fasthtml-0.3.2}/CONTRIBUTING.md +0 -0
- {python-fasthtml-0.3.0 → python-fasthtml-0.3.2}/LICENSE +0 -0
- {python-fasthtml-0.3.0 → python-fasthtml-0.3.2}/MANIFEST.in +0 -0
- {python-fasthtml-0.3.0 → python-fasthtml-0.3.2}/README.md +0 -0
- {python-fasthtml-0.3.0 → python-fasthtml-0.3.2}/fasthtml/authmw.py +0 -0
- {python-fasthtml-0.3.0 → python-fasthtml-0.3.2}/fasthtml/cli.py +0 -0
- {python-fasthtml-0.3.0 → python-fasthtml-0.3.2}/fasthtml/common.py +0 -0
- {python-fasthtml-0.3.0 → python-fasthtml-0.3.2}/fasthtml/components.pyi +0 -0
- {python-fasthtml-0.3.0 → python-fasthtml-0.3.2}/fasthtml/fastapp.py +0 -0
- {python-fasthtml-0.3.0 → python-fasthtml-0.3.2}/fasthtml/ft.py +0 -0
- {python-fasthtml-0.3.0 → python-fasthtml-0.3.2}/fasthtml/js.py +0 -0
- {python-fasthtml-0.3.0 → python-fasthtml-0.3.2}/fasthtml/live_reload.py +0 -0
- {python-fasthtml-0.3.0 → python-fasthtml-0.3.2}/fasthtml/oauth.py +0 -0
- {python-fasthtml-0.3.0 → python-fasthtml-0.3.2}/fasthtml/starlette.py +0 -0
- {python-fasthtml-0.3.0 → python-fasthtml-0.3.2}/fasthtml/svg.py +0 -0
- {python-fasthtml-0.3.0 → python-fasthtml-0.3.2}/fasthtml/toaster.py +0 -0
- {python-fasthtml-0.3.0 → python-fasthtml-0.3.2}/fasthtml/xtend.pyi +0 -0
- {python-fasthtml-0.3.0 → python-fasthtml-0.3.2}/python_fasthtml.egg-info/SOURCES.txt +0 -0
- {python-fasthtml-0.3.0 → python-fasthtml-0.3.2}/python_fasthtml.egg-info/dependency_links.txt +0 -0
- {python-fasthtml-0.3.0 → python-fasthtml-0.3.2}/python_fasthtml.egg-info/entry_points.txt +0 -0
- {python-fasthtml-0.3.0 → python-fasthtml-0.3.2}/python_fasthtml.egg-info/not-zip-safe +0 -0
- {python-fasthtml-0.3.0 → python-fasthtml-0.3.2}/python_fasthtml.egg-info/top_level.txt +0 -0
- {python-fasthtml-0.3.0 → python-fasthtml-0.3.2}/setup.cfg +0 -0
- {python-fasthtml-0.3.0 → python-fasthtml-0.3.2}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: python-fasthtml
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
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
|
|
@@ -15,7 +15,7 @@ Classifier: License :: OSI Approved :: Apache Software License
|
|
|
15
15
|
Requires-Python: >=3.10
|
|
16
16
|
Description-Content-Type: text/markdown
|
|
17
17
|
License-File: LICENSE
|
|
18
|
-
Requires-Dist: fastcore>=1.6.
|
|
18
|
+
Requires-Dist: fastcore>=1.6.6
|
|
19
19
|
Requires-Dist: python-dateutil
|
|
20
20
|
Requires-Dist: starlette>0.33
|
|
21
21
|
Requires-Dist: oauthlib
|
|
@@ -111,6 +111,7 @@ d = { 'settings': { 'branch': 'main',
|
|
|
111
111
|
'fasthtml.xtend.Hidden': ('api/xtend.html#hidden', 'fasthtml/xtend.py'),
|
|
112
112
|
'fasthtml.xtend.Me': ('api/xtend.html#me', 'fasthtml/xtend.py'),
|
|
113
113
|
'fasthtml.xtend.On': ('api/xtend.html#on', 'fasthtml/xtend.py'),
|
|
114
|
+
'fasthtml.xtend.Prev': ('api/xtend.html#prev', 'fasthtml/xtend.py'),
|
|
114
115
|
'fasthtml.xtend.Script': ('api/xtend.html#script', 'fasthtml/xtend.py'),
|
|
115
116
|
'fasthtml.xtend.ScriptX': ('api/xtend.html#scriptx', 'fasthtml/xtend.py'),
|
|
116
117
|
'fasthtml.xtend.Search': ('api/xtend.html#search', 'fasthtml/xtend.py'),
|
|
@@ -20,6 +20,7 @@ from bs4 import BeautifulSoup, Comment
|
|
|
20
20
|
from fastcore.utils import *
|
|
21
21
|
from fastcore.xml import *
|
|
22
22
|
from fastcore.meta import use_kwargs, delegates
|
|
23
|
+
from .core import fh_cfg
|
|
23
24
|
|
|
24
25
|
import types
|
|
25
26
|
|
|
@@ -28,6 +29,7 @@ except ImportError: display=None
|
|
|
28
29
|
|
|
29
30
|
# %% ../nbs/api/01_components.ipynb
|
|
30
31
|
def show(ft,*rest):
|
|
32
|
+
"Renders FT Components into HTML within a Jupyter notebook."
|
|
31
33
|
if rest: ft = (ft,)+rest
|
|
32
34
|
return display.HTML(to_xml(ft))
|
|
33
35
|
|
|
@@ -38,17 +40,20 @@ hx_attrs = 'get post put delete patch trigger target swap include select indicat
|
|
|
38
40
|
hx_attrs = html_attrs + [f'hx_{o}' for o in hx_attrs.split()]
|
|
39
41
|
|
|
40
42
|
# %% ../nbs/api/01_components.ipynb
|
|
41
|
-
_alpine_re = re.compile(r'x_(\w+)_')
|
|
42
|
-
|
|
43
43
|
def attrmap_x(o):
|
|
44
44
|
if o.startswith('_at_'): o = '@'+o[4:]
|
|
45
|
-
o = _alpine_re.sub(r'x-\1:', o, 1)
|
|
46
45
|
return attrmap(o)
|
|
47
46
|
|
|
48
47
|
# %% ../nbs/api/01_components.ipynb
|
|
49
|
-
|
|
48
|
+
fh_cfg['attrmap']=attrmap_x
|
|
49
|
+
fh_cfg['valmap' ]=valmap
|
|
50
|
+
|
|
51
|
+
# %% ../nbs/api/01_components.ipynb
|
|
52
|
+
def ft_html(tag: str, *c, id=None, cls=None, title=None, style=None, attrmap=None, valmap=None, **kwargs):
|
|
53
|
+
if attrmap is None: attrmap=fh_cfg.attrmap
|
|
54
|
+
if valmap is None: valmap =fh_cfg.valmap
|
|
50
55
|
kwargs['id'],kwargs['cls'],kwargs['title'],kwargs['style'] = id,cls,title,style
|
|
51
|
-
tag,c,kw = ft(tag, *c, attrmap=
|
|
56
|
+
tag,c,kw = ft(tag, *c, attrmap=attrmap, valmap=valmap, **kwargs)
|
|
52
57
|
if tag in named and 'id' in kw and 'name' not in kw: kw['name'] = kw['id']
|
|
53
58
|
return FT(tag,c,kw, void_=tag in voids)
|
|
54
59
|
|
|
@@ -90,6 +95,9 @@ def _fill_item(item, obj):
|
|
|
90
95
|
else: attr.pop('checked', '')
|
|
91
96
|
else: attr['value'] = val
|
|
92
97
|
if tag=='textarea': cs=(val,)
|
|
98
|
+
if tag == 'select':
|
|
99
|
+
option = next((o for o in cs if o.tag=='option' and o.get('value')==val), None)
|
|
100
|
+
if option: option.selected = '1'
|
|
93
101
|
return FT(tag,cs,attr,void_=item.void_)
|
|
94
102
|
|
|
95
103
|
# %% ../nbs/api/01_components.ipynb
|
|
@@ -107,7 +115,7 @@ def fill_dataclass(src, dest):
|
|
|
107
115
|
|
|
108
116
|
# %% ../nbs/api/01_components.ipynb
|
|
109
117
|
def find_inputs(e, tags='input', **kw):
|
|
110
|
-
|
|
118
|
+
"Recursively find all elements in `e` with `tags` and attrs matching `kw`"
|
|
111
119
|
if not isinstance(e, (list,tuple)): return []
|
|
112
120
|
inputs = []
|
|
113
121
|
if isinstance(tags,str): tags = [tags]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/api/00_core.ipynb.
|
|
2
2
|
|
|
3
3
|
# %% auto 0
|
|
4
|
-
__all__ = ['empty', 'htmx_hdrs', 'htmxscr', 'htmxwsscr', 'surrsrc', 'scopesrc', 'viewport', 'charset', 'all_meths',
|
|
4
|
+
__all__ = ['empty', 'htmx_hdrs', 'fh_cfg', 'htmxscr', 'htmxwsscr', 'surrsrc', 'scopesrc', 'viewport', 'charset', 'all_meths',
|
|
5
5
|
'is_typeddict', 'is_namedtuple', 'date', 'snake2hyphens', 'HtmxHeaders', 'str2int', 'HttpHeader',
|
|
6
6
|
'form2dict', 'flat_xt', 'Beforeware', 'WS_RouteX', 'RouteX', 'RouterX', 'get_key', 'FastHTML', 'cookie',
|
|
7
7
|
'reg_re_param', 'MiddlewareBase']
|
|
@@ -11,7 +11,6 @@ import json,uuid,inspect,types
|
|
|
11
11
|
|
|
12
12
|
from fastcore.utils import *
|
|
13
13
|
from fastcore.xml import *
|
|
14
|
-
from .xtend import *
|
|
15
14
|
|
|
16
15
|
from types import UnionType, SimpleNamespace as ns, GenericAlias
|
|
17
16
|
from typing import Optional, get_type_hints, get_args, get_origin, Union, Mapping, TypedDict, List, Any
|
|
@@ -86,6 +85,9 @@ def str2int(s)->int:
|
|
|
86
85
|
# %% ../nbs/api/00_core.ipynb
|
|
87
86
|
def _mk_list(t, v): return [t(o) for o in v]
|
|
88
87
|
|
|
88
|
+
# %% ../nbs/api/00_core.ipynb
|
|
89
|
+
fh_cfg = AttrDict(indent=True)
|
|
90
|
+
|
|
89
91
|
# %% ../nbs/api/00_core.ipynb
|
|
90
92
|
def _fix_anno(t):
|
|
91
93
|
"Create appropriate callable type for casting a `str` to type `t` (or first type in `t` if union)"
|
|
@@ -177,7 +179,7 @@ async def _find_p(req, arg:str, p:Parameter):
|
|
|
177
179
|
# We can cast str and list[str] to types; otherwise just return what we have
|
|
178
180
|
if not isinstance(res, (list,str)) or anno is empty: return res
|
|
179
181
|
anno = _fix_anno(anno)
|
|
180
|
-
try: return
|
|
182
|
+
try: return anno(res)
|
|
181
183
|
except ValueError: raise HTTPException(404, req.url.path) from None
|
|
182
184
|
|
|
183
185
|
async def _wrap_req(req, params):
|
|
@@ -226,7 +228,7 @@ def _wrap_ws(ws, data, params):
|
|
|
226
228
|
# %% ../nbs/api/00_core.ipynb
|
|
227
229
|
async def _send_ws(ws, resp):
|
|
228
230
|
if not resp: return
|
|
229
|
-
res = to_xml(resp) if isinstance(resp, (list,tuple)) or hasattr(resp, '__ft__') else resp
|
|
231
|
+
res = to_xml(resp, indent=fh_cfg.indent) if isinstance(resp, (list,tuple)) or hasattr(resp, '__ft__') else resp
|
|
230
232
|
await ws.send_text(res)
|
|
231
233
|
|
|
232
234
|
def _ws_endp(recv, conn=None, disconn=None, hdrs=None, before=None):
|
|
@@ -267,7 +269,7 @@ def _xt_resp(req, resp):
|
|
|
267
269
|
if resp and 'hx-request' not in req.headers and not any(getattr(o, 'tag', '')=='html' for o in resp):
|
|
268
270
|
if not titles: titles = [Title('FastHTML page')]
|
|
269
271
|
resp = Html(Head(*titles, *flat_xt(req.hdrs)), Body(bdy, *flat_xt(req.ftrs), **req.bodykw), **req.htmlkw)
|
|
270
|
-
return HTMLResponse(to_xml(resp), headers=http_hdrs)
|
|
272
|
+
return HTMLResponse(to_xml(resp, indent=fh_cfg.indent), headers=http_hdrs)
|
|
271
273
|
|
|
272
274
|
# %% ../nbs/api/00_core.ipynb
|
|
273
275
|
def _resp(req, resp, cls=empty):
|
|
@@ -307,7 +309,7 @@ class RouteX(Route):
|
|
|
307
309
|
if not resp:
|
|
308
310
|
if isinstance(b, Beforeware): bf,skip = b.f,b.skip
|
|
309
311
|
else: bf,skip = b,[]
|
|
310
|
-
if not any(re.
|
|
312
|
+
if not any(re.fullmatch(r, req.url.path) for r in skip):
|
|
311
313
|
resp = await _wrap_call(bf, req, _sig(bf).parameters)
|
|
312
314
|
if not resp: resp = await _wrap_call(self.f, req, self.sig.parameters)
|
|
313
315
|
for a in self.after:
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
# %% auto 0
|
|
4
4
|
__all__ = ['picocss', 'picolink', 'picocondcss', 'picocondlink', 'set_pico_cls', 'A', 'Form', 'AX', 'Checkbox', 'Card', 'Group',
|
|
5
5
|
'Search', 'Grid', 'DialogX', 'Hidden', 'Container', 'Script', 'Style', 'double_braces', 'undouble_braces',
|
|
6
|
-
'loose_format', 'ScriptX', 'replace_css_vars', 'StyleX', 'On', 'Me', '
|
|
7
|
-
'Favicon', 'jsd']
|
|
6
|
+
'loose_format', 'ScriptX', 'replace_css_vars', 'StyleX', 'On', 'Me', 'Prev', 'Any', 'run_js', 'Titled',
|
|
7
|
+
'Socials', 'Favicon', 'jsd']
|
|
8
8
|
|
|
9
9
|
# %% ../nbs/api/02_xtend.ipynb
|
|
10
10
|
from dataclasses import dataclass, asdict
|
|
@@ -185,6 +185,11 @@ def Me(code:str, sel:str=''):
|
|
|
185
185
|
if sel: sel=f'"{sel}"'
|
|
186
186
|
return Script(f'(async (ee = me({sel})) => {{\nlet e = me(ee);\n{code}\n}})()\n')
|
|
187
187
|
|
|
188
|
+
# %% ../nbs/api/02_xtend.ipynb
|
|
189
|
+
def Prev(code:str):
|
|
190
|
+
"An async surreal.js script block on selector `me('-')`"
|
|
191
|
+
return Me(code, '-')
|
|
192
|
+
|
|
188
193
|
# %% ../nbs/api/02_xtend.ipynb
|
|
189
194
|
def Any(code:str, sel:str):
|
|
190
195
|
"An async surreal.js script block on selector `any(sel)`"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: python-fasthtml
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
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
|
|
@@ -15,7 +15,7 @@ Classifier: License :: OSI Approved :: Apache Software License
|
|
|
15
15
|
Requires-Python: >=3.10
|
|
16
16
|
Description-Content-Type: text/markdown
|
|
17
17
|
License-File: LICENSE
|
|
18
|
-
Requires-Dist: fastcore>=1.6.
|
|
18
|
+
Requires-Dist: fastcore>=1.6.6
|
|
19
19
|
Requires-Dist: python-dateutil
|
|
20
20
|
Requires-Dist: starlette>0.33
|
|
21
21
|
Requires-Dist: oauthlib
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
[DEFAULT]
|
|
2
2
|
repo = fasthtml
|
|
3
3
|
lib_name = fasthtml
|
|
4
|
-
version = 0.3.
|
|
4
|
+
version = 0.3.2
|
|
5
5
|
min_python = 3.10
|
|
6
6
|
license = apache2
|
|
7
|
-
requirements = fastcore>=1.6.
|
|
7
|
+
requirements = fastcore>=1.6.6 python-dateutil starlette>0.33 oauthlib itsdangerous uvicorn[standard]>=0.30 httpx fastlite>=0.0.6 python-multipart beautifulsoup4
|
|
8
8
|
dev_requirements = ipython lxml
|
|
9
9
|
black_formatting = False
|
|
10
10
|
conda_user = fastai
|
|
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.3.0 → python-fasthtml-0.3.2}/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
|