python-fasthtml 0.3.7__tar.gz → 0.4.0__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 (36) hide show
  1. {python-fasthtml-0.3.7/python_fasthtml.egg-info → python-fasthtml-0.4.0}/PKG-INFO +2 -2
  2. python-fasthtml-0.4.0/fasthtml/__init__.py +2 -0
  3. {python-fasthtml-0.3.7 → python-fasthtml-0.4.0}/fasthtml/_modidx.py +1 -0
  4. python-fasthtml-0.4.0/fasthtml/basics.py +4 -0
  5. {python-fasthtml-0.3.7 → python-fasthtml-0.4.0}/fasthtml/common.py +4 -1
  6. {python-fasthtml-0.3.7 → python-fasthtml-0.4.0}/fasthtml/components.py +7 -6
  7. {python-fasthtml-0.3.7 → python-fasthtml-0.4.0}/fasthtml/core.py +5 -5
  8. {python-fasthtml-0.3.7 → python-fasthtml-0.4.0}/fasthtml/fastapp.py +2 -1
  9. {python-fasthtml-0.3.7 → python-fasthtml-0.4.0}/fasthtml/js.py +1 -1
  10. {python-fasthtml-0.3.7 → python-fasthtml-0.4.0}/fasthtml/live_reload.py +1 -1
  11. {python-fasthtml-0.3.7 → python-fasthtml-0.4.0/python_fasthtml.egg-info}/PKG-INFO +2 -2
  12. {python-fasthtml-0.3.7 → python-fasthtml-0.4.0}/python_fasthtml.egg-info/SOURCES.txt +1 -0
  13. {python-fasthtml-0.3.7 → python-fasthtml-0.4.0}/python_fasthtml.egg-info/requires.txt +1 -1
  14. {python-fasthtml-0.3.7 → python-fasthtml-0.4.0}/settings.ini +2 -2
  15. python-fasthtml-0.3.7/fasthtml/__init__.py +0 -7
  16. {python-fasthtml-0.3.7 → python-fasthtml-0.4.0}/CONTRIBUTING.md +0 -0
  17. {python-fasthtml-0.3.7 → python-fasthtml-0.4.0}/LICENSE +0 -0
  18. {python-fasthtml-0.3.7 → python-fasthtml-0.4.0}/MANIFEST.in +0 -0
  19. {python-fasthtml-0.3.7 → python-fasthtml-0.4.0}/README.md +0 -0
  20. {python-fasthtml-0.3.7 → python-fasthtml-0.4.0}/fasthtml/authmw.py +0 -0
  21. {python-fasthtml-0.3.7 → python-fasthtml-0.4.0}/fasthtml/cli.py +0 -0
  22. {python-fasthtml-0.3.7 → python-fasthtml-0.4.0}/fasthtml/components.pyi +0 -0
  23. {python-fasthtml-0.3.7 → python-fasthtml-0.4.0}/fasthtml/ft.py +0 -0
  24. {python-fasthtml-0.3.7 → python-fasthtml-0.4.0}/fasthtml/katex.js +0 -0
  25. {python-fasthtml-0.3.7 → python-fasthtml-0.4.0}/fasthtml/oauth.py +0 -0
  26. {python-fasthtml-0.3.7 → python-fasthtml-0.4.0}/fasthtml/starlette.py +0 -0
  27. {python-fasthtml-0.3.7 → python-fasthtml-0.4.0}/fasthtml/svg.py +0 -0
  28. {python-fasthtml-0.3.7 → python-fasthtml-0.4.0}/fasthtml/toaster.py +0 -0
  29. {python-fasthtml-0.3.7 → python-fasthtml-0.4.0}/fasthtml/xtend.py +0 -0
  30. {python-fasthtml-0.3.7 → python-fasthtml-0.4.0}/fasthtml/xtend.pyi +0 -0
  31. {python-fasthtml-0.3.7 → python-fasthtml-0.4.0}/python_fasthtml.egg-info/dependency_links.txt +0 -0
  32. {python-fasthtml-0.3.7 → python-fasthtml-0.4.0}/python_fasthtml.egg-info/entry_points.txt +0 -0
  33. {python-fasthtml-0.3.7 → python-fasthtml-0.4.0}/python_fasthtml.egg-info/not-zip-safe +0 -0
  34. {python-fasthtml-0.3.7 → python-fasthtml-0.4.0}/python_fasthtml.egg-info/top_level.txt +0 -0
  35. {python-fasthtml-0.3.7 → python-fasthtml-0.4.0}/setup.cfg +0 -0
  36. {python-fasthtml-0.3.7 → python-fasthtml-0.4.0}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-fasthtml
3
- Version: 0.3.7
3
+ Version: 0.4.0
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.9
18
+ Requires-Dist: fastcore>=1.7.0
19
19
  Requires-Dist: python-dateutil
20
20
  Requires-Dist: starlette>0.33
21
21
  Requires-Dist: oauthlib
@@ -0,0 +1,2 @@
1
+ __version__ = "0.4.0"
2
+ from .core import *
@@ -6,6 +6,7 @@ d = { 'settings': { 'branch': 'main',
6
6
  'git_url': 'https://github.com/AnswerDotAI/fasthtml',
7
7
  'lib_path': 'fasthtml'},
8
8
  'syms': { 'fasthtml.authmw': {},
9
+ 'fasthtml.basics': {},
9
10
  'fasthtml.cli': { 'fasthtml.cli._run': ('api/cli.html#_run', 'fasthtml/cli.py'),
10
11
  'fasthtml.cli.railway_deploy': ('api/cli.html#railway_deploy', 'fasthtml/cli.py'),
11
12
  'fasthtml.cli.railway_link': ('api/cli.html#railway_link', 'fasthtml/cli.py')},
@@ -0,0 +1,4 @@
1
+ from .core import *
2
+ from .components import *
3
+ from .xtend import *
4
+
@@ -6,6 +6,9 @@ from fastcore.utils import *
6
6
  from fastcore.xml import *
7
7
  from sqlite_minutils import Database
8
8
  from fastlite import *
9
- from . import *
9
+ from .basics import *
10
+ from .authmw import *
11
+ from .live_reload import *
12
+ from .toaster import *
10
13
  from .js import *
11
14
  from .fastapp import *
@@ -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 fastcore.test import *
23
24
  from .core import fh_cfg
24
25
 
25
26
  import types, json
@@ -53,7 +54,7 @@ def ft_html(tag: str, *c, id=None, cls=None, title=None, style=None, attrmap=Non
53
54
  if attrmap is None: attrmap=fh_cfg.attrmap
54
55
  if valmap is None: valmap =fh_cfg.valmap
55
56
  kwargs['id'],kwargs['cls'],kwargs['title'],kwargs['style'] = id,cls,title,style
56
- tag,c,kw = ft(tag, *c, attrmap=attrmap, valmap=valmap, **kwargs)
57
+ tag,c,kw = ft(tag, *c, attrmap=attrmap, valmap=valmap, **kwargs).list
57
58
  if tag in named and 'id' in kw and 'name' not in kw: kw['name'] = kw['id']
58
59
  return FT(tag,c,kw, void_=tag in voids)
59
60
 
@@ -85,7 +86,7 @@ def File(fname):
85
86
  # %% ../nbs/api/01_components.ipynb
86
87
  def _fill_item(item, obj):
87
88
  if not isinstance(item,list): return item
88
- tag,cs,attr = item
89
+ tag,cs,attr = item.list
89
90
  if isinstance(cs,tuple): cs = tuple(_fill_item(o, obj) for o in cs)
90
91
  name = attr.get('name', None)
91
92
  val = None if name is None else obj.get(name, None)
@@ -117,14 +118,14 @@ def fill_dataclass(src, dest):
117
118
  # %% ../nbs/api/01_components.ipynb
118
119
  def find_inputs(e, tags='input', **kw):
119
120
  "Recursively find all elements in `e` with `tags` and attrs matching `kw`"
120
- if not isinstance(e, (list,tuple)): return []
121
+ if not isinstance(e, (list,tuple,FT)): return []
121
122
  inputs = []
122
123
  if isinstance(tags,str): tags = [tags]
123
124
  elif tags is None: tags = []
124
125
  cs = e
125
- if isinstance(e, list):
126
- tag,cs,attr = e
127
- if e[0] in tags and kw.items()<=e[2].items(): inputs.append(e)
126
+ if isinstance(e, FT):
127
+ tag,cs,attr = e.list
128
+ if tag in tags and kw.items()<=attr.items(): inputs.append(e)
128
129
  for o in cs: inputs += find_inputs(o, tags, **kw)
129
130
  return inputs
130
131
 
@@ -189,11 +189,11 @@ async def _wrap_req(req, params):
189
189
 
190
190
  # %% ../nbs/api/00_core.ipynb
191
191
  def flat_xt(lst):
192
- "Flatten lists, except for `FT`s"
192
+ "Flatten lists"
193
193
  result = []
194
194
  if isinstance(lst,(FT,str)): lst=[lst]
195
195
  for item in lst:
196
- if isinstance(item, (list,tuple)) and not isinstance(item, FT): result.extend(item)
196
+ if isinstance(item, (list,tuple)): result.extend(item)
197
197
  else: result.append(item)
198
198
  return result
199
199
 
@@ -234,7 +234,7 @@ def _wrap_ws(ws, data, params):
234
234
  # %% ../nbs/api/00_core.ipynb
235
235
  async def _send_ws(ws, resp):
236
236
  if not resp: return
237
- res = to_xml(resp, indent=fh_cfg.indent) if isinstance(resp, (list,tuple)) or hasattr(resp, '__ft__') else resp
237
+ res = to_xml(resp, indent=fh_cfg.indent) if isinstance(resp, (list,tuple,FT)) or hasattr(resp, '__ft__') else resp
238
238
  await ws.send_text(res)
239
239
 
240
240
  def _ws_endp(recv, conn=None, disconn=None, hdrs=None, before=None):
@@ -313,7 +313,7 @@ def _find_targets(req, resp):
313
313
  def _apply_ft(o):
314
314
  if isinstance(o, tuple): o = tuple(_apply_ft(c) for c in o)
315
315
  if hasattr(o, '__ft__'): o = o.__ft__()
316
- if isinstance(o, FT): o[1] = [_apply_ft(c) for c in o[1]]
316
+ if isinstance(o, FT): o.children = [_apply_ft(c) for c in o.children]
317
317
  return o
318
318
 
319
319
  def _to_xml(req, resp, indent):
@@ -341,7 +341,7 @@ def _resp(req, resp, cls=empty):
341
341
  if isinstance(resp, FileResponse) and not os.path.exists(resp.path): raise HTTPException(404, resp.path)
342
342
  if isinstance(resp, Response): return resp
343
343
  if cls is not empty: return cls(resp)
344
- if isinstance(resp, (list,tuple,HttpHeader)) or hasattr(resp, '__ft__'): return _xt_resp(req, resp)
344
+ if isinstance(resp, (list,tuple,HttpHeader,FT)) or hasattr(resp, '__ft__'): return _xt_resp(req, resp)
345
345
  if isinstance(resp, str): cls = HTMLResponse
346
346
  elif isinstance(resp, Mapping): cls = JSONResponse
347
347
  else:
@@ -6,7 +6,8 @@ from __future__ import annotations
6
6
  import inspect,uvicorn
7
7
  from fastcore.utils import *
8
8
  from fastlite import *
9
- from . import *
9
+ from .basics import *
10
+ from .starlette import *
10
11
  from .live_reload import FastHTMLWithLiveReload
11
12
 
12
13
  # %% auto 0
@@ -79,7 +79,7 @@ htmx.onLoad(hljs.highlightAll);""" % sel
79
79
  # %% ../nbs/api/03_js.ipynb
80
80
  def SortableJS(
81
81
  sel='.sortable', # CSS selector for sortable elements
82
- ghost_class='blue-background-class' # When an element is being dragged, this is the class used to distingish it from the rest
82
+ ghost_class='blue-background-class' # When an element is being dragged, this is the class used to distinguish it from the rest
83
83
  ):
84
84
  src = """
85
85
  import {Sortable} from 'https://cdn.jsdelivr.net/npm/sortablejs/+esm';
@@ -1,5 +1,5 @@
1
1
  from starlette.routing import WebSocketRoute
2
- from fasthtml import FastHTML, Script
2
+ from fasthtml.basics import FastHTML, Script
3
3
 
4
4
  __all__ = ["FastHTMLWithLiveReload"]
5
5
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-fasthtml
3
- Version: 0.3.7
3
+ Version: 0.4.0
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.9
18
+ Requires-Dist: fastcore>=1.7.0
19
19
  Requires-Dist: python-dateutil
20
20
  Requires-Dist: starlette>0.33
21
21
  Requires-Dist: oauthlib
@@ -7,6 +7,7 @@ setup.py
7
7
  fasthtml/__init__.py
8
8
  fasthtml/_modidx.py
9
9
  fasthtml/authmw.py
10
+ fasthtml/basics.py
10
11
  fasthtml/cli.py
11
12
  fasthtml/common.py
12
13
  fasthtml/components.py
@@ -1,4 +1,4 @@
1
- fastcore>=1.6.9
1
+ fastcore>=1.7.0
2
2
  python-dateutil
3
3
  starlette>0.33
4
4
  oauthlib
@@ -1,10 +1,10 @@
1
1
  [DEFAULT]
2
2
  repo = fasthtml
3
3
  lib_name = fasthtml
4
- version = 0.3.7
4
+ version = 0.4.0
5
5
  min_python = 3.10
6
6
  license = apache2
7
- requirements = fastcore>=1.6.9 python-dateutil starlette>0.33 oauthlib itsdangerous uvicorn[standard]>=0.30 httpx fastlite>=0.0.6 python-multipart beautifulsoup4
7
+ requirements = fastcore>=1.7.0 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
@@ -1,7 +0,0 @@
1
- __version__ = "0.3.7"
2
- from .core import *
3
- from .authmw import *
4
- from .components import *
5
- from .xtend import *
6
- from .live_reload import *
7
- from .toaster import *
File without changes