python-fasthtml 0.0.14__tar.gz → 0.0.16__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 (29) hide show
  1. {python-fasthtml-0.0.14/python_fasthtml.egg-info → python-fasthtml-0.0.16}/PKG-INFO +5 -5
  2. {python-fasthtml-0.0.14 → python-fasthtml-0.0.16}/README.md +3 -3
  3. {python-fasthtml-0.0.14 → python-fasthtml-0.0.16}/fasthtml/__init__.py +1 -1
  4. {python-fasthtml-0.0.14 → python-fasthtml-0.0.16}/fasthtml/_modidx.py +3 -2
  5. {python-fasthtml-0.0.14 → python-fasthtml-0.0.16}/fasthtml/authmw.py +2 -1
  6. {python-fasthtml-0.0.14 → python-fasthtml-0.0.16}/fasthtml/components.py +1 -1
  7. {python-fasthtml-0.0.14 → python-fasthtml-0.0.16}/fasthtml/core.py +1 -0
  8. {python-fasthtml-0.0.14 → python-fasthtml-0.0.16}/fasthtml/fastapp.py +2 -1
  9. {python-fasthtml-0.0.14 → python-fasthtml-0.0.16}/fasthtml/live_reload.py +1 -1
  10. {python-fasthtml-0.0.14 → python-fasthtml-0.0.16}/fasthtml/xtend.py +11 -3
  11. {python-fasthtml-0.0.14 → python-fasthtml-0.0.16/python_fasthtml.egg-info}/PKG-INFO +5 -5
  12. {python-fasthtml-0.0.14 → python-fasthtml-0.0.16}/python_fasthtml.egg-info/SOURCES.txt +1 -1
  13. {python-fasthtml-0.0.14 → python-fasthtml-0.0.16}/python_fasthtml.egg-info/requires.txt +1 -1
  14. {python-fasthtml-0.0.14 → python-fasthtml-0.0.16}/settings.ini +2 -2
  15. {python-fasthtml-0.0.14 → python-fasthtml-0.0.16}/LICENSE +0 -0
  16. {python-fasthtml-0.0.14 → python-fasthtml-0.0.16}/MANIFEST.in +0 -0
  17. {python-fasthtml-0.0.14 → python-fasthtml-0.0.16}/fasthtml/cli.py +0 -0
  18. /python-fasthtml-0.0.14/fasthtml/all.py → /python-fasthtml-0.0.16/fasthtml/common.py +0 -0
  19. {python-fasthtml-0.0.14 → python-fasthtml-0.0.16}/fasthtml/components.pyi +0 -0
  20. {python-fasthtml-0.0.14 → python-fasthtml-0.0.16}/fasthtml/js.py +0 -0
  21. {python-fasthtml-0.0.14 → python-fasthtml-0.0.16}/fasthtml/oauth.py +0 -0
  22. {python-fasthtml-0.0.14 → python-fasthtml-0.0.16}/fasthtml/starlette.py +0 -0
  23. {python-fasthtml-0.0.14 → python-fasthtml-0.0.16}/fasthtml/xtend.pyi +0 -0
  24. {python-fasthtml-0.0.14 → python-fasthtml-0.0.16}/python_fasthtml.egg-info/dependency_links.txt +0 -0
  25. {python-fasthtml-0.0.14 → python-fasthtml-0.0.16}/python_fasthtml.egg-info/entry_points.txt +0 -0
  26. {python-fasthtml-0.0.14 → python-fasthtml-0.0.16}/python_fasthtml.egg-info/not-zip-safe +0 -0
  27. {python-fasthtml-0.0.14 → python-fasthtml-0.0.16}/python_fasthtml.egg-info/top_level.txt +0 -0
  28. {python-fasthtml-0.0.14 → python-fasthtml-0.0.16}/setup.cfg +0 -0
  29. {python-fasthtml-0.0.14 → python-fasthtml-0.0.16}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-fasthtml
3
- Version: 0.0.14
3
+ Version: 0.0.16
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.5.45
18
+ Requires-Dist: fastcore>=1.5.46
19
19
  Requires-Dist: python-dateutil
20
20
  Requires-Dist: starlette
21
21
  Requires-Dist: oauthlib
@@ -68,7 +68,7 @@ For a minimal app, create a file “main.py” as follows:
68
68
  **main.py**
69
69
 
70
70
  ``` python
71
- from fasthtml.all import *
71
+ from fasthtml.common import *
72
72
  import uvicorn
73
73
 
74
74
  app = FastHTML()
@@ -86,10 +86,10 @@ if __name__ == '__main__':
86
86
 
87
87
  ## How to use
88
88
 
89
- Import from `fasthtml.all`:
89
+ Import from `fasthtml.common`:
90
90
 
91
91
  ``` python
92
- from fasthtml.all import *
92
+ from fasthtml.common import *
93
93
  ```
94
94
 
95
95
  Create your app.
@@ -37,7 +37,7 @@ For a minimal app, create a file “main.py” as follows:
37
37
  **main.py**
38
38
 
39
39
  ``` python
40
- from fasthtml.all import *
40
+ from fasthtml.common import *
41
41
  import uvicorn
42
42
 
43
43
  app = FastHTML()
@@ -55,10 +55,10 @@ if __name__ == '__main__':
55
55
 
56
56
  ## How to use
57
57
 
58
- Import from `fasthtml.all`:
58
+ Import from `fasthtml.common`:
59
59
 
60
60
  ``` python
61
- from fasthtml.all import *
61
+ from fasthtml.common import *
62
62
  ```
63
63
 
64
64
  Create your app.
@@ -1,4 +1,4 @@
1
- __version__ = "0.0.14"
1
+ __version__ = "0.0.16"
2
2
  from .core import *
3
3
  from .authmw import *
4
4
  from .components import *
@@ -5,9 +5,9 @@ d = { 'settings': { 'branch': 'main',
5
5
  'doc_host': 'https://AnswerDotAI.github.io',
6
6
  'git_url': 'https://github.com/AnswerDotAI/fasthtml',
7
7
  'lib_path': 'fasthtml'},
8
- 'syms': { 'fasthtml.all': {},
9
- 'fasthtml.authmw': {},
8
+ 'syms': { 'fasthtml.authmw': {},
10
9
  'fasthtml.cli': {'fasthtml.cli.railway_link': ('cli.html#railway_link', 'fasthtml/cli.py')},
10
+ 'fasthtml.common': {},
11
11
  'fasthtml.components': { 'fasthtml.components.__getattr__': ('components.html#__getattr__', 'fasthtml/components.py'),
12
12
  'fasthtml.components._fill_item': ('components.html#_fill_item', 'fasthtml/components.py'),
13
13
  'fasthtml.components.fill_dataclass': ('components.html#fill_dataclass', 'fasthtml/components.py'),
@@ -47,5 +47,6 @@ d = { 'settings': { 'branch': 'main',
47
47
  'fasthtml.xtend.Script': ('xtend.html#script', 'fasthtml/xtend.py'),
48
48
  'fasthtml.xtend.Search': ('xtend.html#search', 'fasthtml/xtend.py'),
49
49
  'fasthtml.xtend.Style': ('xtend.html#style', 'fasthtml/xtend.py'),
50
+ 'fasthtml.xtend.Titled': ('xtend.html#titled', 'fasthtml/xtend.py'),
50
51
  'fasthtml.xtend.jsd': ('xtend.html#jsd', 'fasthtml/xtend.py'),
51
52
  'fasthtml.xtend.set_pico_cls': ('xtend.html#set_pico_cls', 'fasthtml/xtend.py')}}}
@@ -2,6 +2,7 @@ import base64, binascii
2
2
  from fasthtml.core import *
3
3
  from fasthtml.starlette import *
4
4
  from typing import Mapping
5
+ from hmac import compare_digest
5
6
 
6
7
  auth_hdrs = {'WWW-Authenticate': 'Basic realm="login"'}
7
8
 
@@ -38,7 +39,7 @@ def user_pwd_auth(lookup=None, skip=None, **kwargs):
38
39
  def cb(u,p):
39
40
  if u=='logout' or not u or not p: return
40
41
  if callable(lookup): return lookup(u,p)
41
- return kwargs.get(u,None) == p
42
+ return compare_digest(kwargs.get(u,'').encode("utf-8"), p.encode("utf-8"))
42
43
  return Middleware(BasicAuthMiddleware, cb=cb, skip=skip)
43
44
 
44
45
  def basic_logout(request):
@@ -123,7 +123,7 @@ def html2xt(html):
123
123
  attrs = []
124
124
  for key, value in elm.attrs.items():
125
125
  if isinstance(value,(tuple,list)): value = " ".join(value)
126
- attrs.append(f'{rev_map.get(key, key)}={value!r}')
126
+ attrs.append(f'{rev_map.get(key, key).replace("-", "_")}={value!r}')
127
127
  spc = " "*lvl*2
128
128
  onlychild = not cts or (len(cts)==1 and isinstance(cts[0],str))
129
129
  j = ', ' if onlychild else f',\n{spc}'
@@ -159,6 +159,7 @@ def _xt_resp(req, resp, hdrs, **bodykw):
159
159
  return HTMLResponse(to_xml(resp), headers=http_hdrs)
160
160
 
161
161
  def _wrap_resp(req, resp, cls, hdrs, **bodykw):
162
+ if isinstance(resp, FileResponse) and not os.path.exists(resp.path): raise HTTPException(404, resp.path)
162
163
  if isinstance(resp, Response): return resp
163
164
  if cls is not empty: return cls(resp)
164
165
  if isinstance(resp, (list,tuple)): return _xt_resp(req, resp, hdrs, **bodykw)
@@ -1,4 +1,4 @@
1
- from fasthtml.all import *
1
+ from fasthtml.common import *
2
2
 
3
3
  def get_tbl(dt, nm, schema):
4
4
  render = schema.pop('render', None)
@@ -30,3 +30,4 @@ target = dict(hx_target='main', hx_swap='outerHTML')
30
30
 
31
31
  def Container(*cs, **kwargs): return Main(*cs, **kwargs, cls='container', hx_push_url='true', hx_swap_oob='true', id='main')
32
32
  def Page(title, *con): return Title(title), Container(H1(title), *con)
33
+
@@ -45,7 +45,7 @@ class FastHTMLWithLiveReload(FastHTML):
45
45
  for "developer has saved some changes".
46
46
 
47
47
  Usage
48
- >>> from fasthtml.all import *
48
+ >>> from fasthtml.common import *
49
49
  >>> app = FastHTMLWithLiveReload()
50
50
 
51
51
  Run:
@@ -2,7 +2,7 @@
2
2
 
3
3
  # %% auto 0
4
4
  __all__ = ['picocss', 'picolink', 'picocondcss', 'picocondlink', 'set_pico_cls', 'Html', 'A', 'AX', 'Checkbox', 'Card', 'Group',
5
- 'Search', 'Grid', 'DialogX', 'Hidden', 'Script', 'Style', 'jsd']
5
+ 'Search', 'Grid', 'DialogX', 'Hidden', 'Script', 'Style', 'Titled', 'jsd']
6
6
 
7
7
  # %% ../nbs/02_xtend.ipynb 2
8
8
  from dataclasses import dataclass, asdict
@@ -17,9 +17,11 @@ except ImportError: display=None
17
17
 
18
18
  # %% ../nbs/02_xtend.ipynb 4
19
19
  picocss = "https://cdn.jsdelivr.net/npm/@picocss/pico@latest/css/pico.min.css"
20
- picolink = Link(rel="stylesheet", href=picocss)
20
+ picolink = (Link(rel="stylesheet", href=picocss),
21
+ Style(":root { --pico-font-size: 100%; }"))
21
22
  picocondcss = "https://cdn.jsdelivr.net/npm/@picocss/pico@latest/css/pico.conditional.min.css"
22
- picocondlink = Link(rel="stylesheet", href=picocondcss)
23
+ picocondlink = (Link(rel="stylesheet", href=picocondcss),
24
+ Style(":root { --pico-font-size: 100%; }"))
23
25
 
24
26
  # %% ../nbs/02_xtend.ipynb 7
25
27
  def set_pico_cls():
@@ -110,6 +112,12 @@ def Style(css:str="", **kwargs):
110
112
  return xt_html('style', NotStr(css), **kwargs)
111
113
 
112
114
  # %% ../nbs/02_xtend.ipynb 30
115
+ @delegates(xt_hx, keep=True)
116
+ def Titled(title:str="FastHTML app", *args, **kwargs):
117
+ "An HTML partial containing a `Title`, and `H1`, and any provided children"
118
+ return Title(title), Main(H1(title), *args, cls="container", **kwargs)
119
+
120
+ # %% ../nbs/02_xtend.ipynb 31
113
121
  def jsd(org, repo, root, path, typ='script', ver=None, esm=False, **kwargs):
114
122
  "jsdelivr `Script` or CSS `Link` tag, or URL"
115
123
  ver = '@'+ver if ver else ''
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-fasthtml
3
- Version: 0.0.14
3
+ Version: 0.0.16
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.5.45
18
+ Requires-Dist: fastcore>=1.5.46
19
19
  Requires-Dist: python-dateutil
20
20
  Requires-Dist: starlette
21
21
  Requires-Dist: oauthlib
@@ -68,7 +68,7 @@ For a minimal app, create a file “main.py” as follows:
68
68
  **main.py**
69
69
 
70
70
  ``` python
71
- from fasthtml.all import *
71
+ from fasthtml.common import *
72
72
  import uvicorn
73
73
 
74
74
  app = FastHTML()
@@ -86,10 +86,10 @@ if __name__ == '__main__':
86
86
 
87
87
  ## How to use
88
88
 
89
- Import from `fasthtml.all`:
89
+ Import from `fasthtml.common`:
90
90
 
91
91
  ``` python
92
- from fasthtml.all import *
92
+ from fasthtml.common import *
93
93
  ```
94
94
 
95
95
  Create your app.
@@ -5,9 +5,9 @@ settings.ini
5
5
  setup.py
6
6
  fasthtml/__init__.py
7
7
  fasthtml/_modidx.py
8
- fasthtml/all.py
9
8
  fasthtml/authmw.py
10
9
  fasthtml/cli.py
10
+ fasthtml/common.py
11
11
  fasthtml/components.py
12
12
  fasthtml/components.pyi
13
13
  fasthtml/core.py
@@ -1,4 +1,4 @@
1
- fastcore>=1.5.45
1
+ fastcore>=1.5.46
2
2
  python-dateutil
3
3
  starlette
4
4
  oauthlib
@@ -1,10 +1,10 @@
1
1
  [DEFAULT]
2
2
  repo = fasthtml
3
3
  lib_name = fasthtml
4
- version = 0.0.14
4
+ version = 0.0.16
5
5
  min_python = 3.10
6
6
  license = apache2
7
- requirements = fastcore>=1.5.45 python-dateutil starlette oauthlib itsdangerous uvicorn[standard] httpx fastlite>=0.0.6 python-multipart beautifulsoup4
7
+ requirements = fastcore>=1.5.46 python-dateutil starlette oauthlib itsdangerous uvicorn[standard] httpx fastlite>=0.0.6 python-multipart beautifulsoup4
8
8
  dev_requirements = ipython lxml
9
9
  black_formatting = False
10
10
  conda_user = fastai