python-fasthtml 0.4.0__tar.gz → 0.4.1__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.4.0/python_fasthtml.egg-info → python-fasthtml-0.4.1}/PKG-INFO +1 -1
  2. python-fasthtml-0.4.1/fasthtml/__init__.py +2 -0
  3. {python-fasthtml-0.4.0 → python-fasthtml-0.4.1}/fasthtml/_modidx.py +1 -0
  4. {python-fasthtml-0.4.0 → python-fasthtml-0.4.1}/fasthtml/components.py +1 -1
  5. {python-fasthtml-0.4.0 → python-fasthtml-0.4.1}/fasthtml/core.py +27 -16
  6. {python-fasthtml-0.4.0 → python-fasthtml-0.4.1/python_fasthtml.egg-info}/PKG-INFO +1 -1
  7. {python-fasthtml-0.4.0 → python-fasthtml-0.4.1}/settings.ini +1 -1
  8. python-fasthtml-0.4.0/fasthtml/__init__.py +0 -2
  9. {python-fasthtml-0.4.0 → python-fasthtml-0.4.1}/CONTRIBUTING.md +0 -0
  10. {python-fasthtml-0.4.0 → python-fasthtml-0.4.1}/LICENSE +0 -0
  11. {python-fasthtml-0.4.0 → python-fasthtml-0.4.1}/MANIFEST.in +0 -0
  12. {python-fasthtml-0.4.0 → python-fasthtml-0.4.1}/README.md +0 -0
  13. {python-fasthtml-0.4.0 → python-fasthtml-0.4.1}/fasthtml/authmw.py +0 -0
  14. {python-fasthtml-0.4.0 → python-fasthtml-0.4.1}/fasthtml/basics.py +0 -0
  15. {python-fasthtml-0.4.0 → python-fasthtml-0.4.1}/fasthtml/cli.py +0 -0
  16. {python-fasthtml-0.4.0 → python-fasthtml-0.4.1}/fasthtml/common.py +0 -0
  17. {python-fasthtml-0.4.0 → python-fasthtml-0.4.1}/fasthtml/components.pyi +0 -0
  18. {python-fasthtml-0.4.0 → python-fasthtml-0.4.1}/fasthtml/fastapp.py +0 -0
  19. {python-fasthtml-0.4.0 → python-fasthtml-0.4.1}/fasthtml/ft.py +0 -0
  20. {python-fasthtml-0.4.0 → python-fasthtml-0.4.1}/fasthtml/js.py +0 -0
  21. {python-fasthtml-0.4.0 → python-fasthtml-0.4.1}/fasthtml/katex.js +0 -0
  22. {python-fasthtml-0.4.0 → python-fasthtml-0.4.1}/fasthtml/live_reload.py +0 -0
  23. {python-fasthtml-0.4.0 → python-fasthtml-0.4.1}/fasthtml/oauth.py +0 -0
  24. {python-fasthtml-0.4.0 → python-fasthtml-0.4.1}/fasthtml/starlette.py +0 -0
  25. {python-fasthtml-0.4.0 → python-fasthtml-0.4.1}/fasthtml/svg.py +0 -0
  26. {python-fasthtml-0.4.0 → python-fasthtml-0.4.1}/fasthtml/toaster.py +0 -0
  27. {python-fasthtml-0.4.0 → python-fasthtml-0.4.1}/fasthtml/xtend.py +0 -0
  28. {python-fasthtml-0.4.0 → python-fasthtml-0.4.1}/fasthtml/xtend.pyi +0 -0
  29. {python-fasthtml-0.4.0 → python-fasthtml-0.4.1}/python_fasthtml.egg-info/SOURCES.txt +0 -0
  30. {python-fasthtml-0.4.0 → python-fasthtml-0.4.1}/python_fasthtml.egg-info/dependency_links.txt +0 -0
  31. {python-fasthtml-0.4.0 → python-fasthtml-0.4.1}/python_fasthtml.egg-info/entry_points.txt +0 -0
  32. {python-fasthtml-0.4.0 → python-fasthtml-0.4.1}/python_fasthtml.egg-info/not-zip-safe +0 -0
  33. {python-fasthtml-0.4.0 → python-fasthtml-0.4.1}/python_fasthtml.egg-info/requires.txt +0 -0
  34. {python-fasthtml-0.4.0 → python-fasthtml-0.4.1}/python_fasthtml.egg-info/top_level.txt +0 -0
  35. {python-fasthtml-0.4.0 → python-fasthtml-0.4.1}/setup.cfg +0 -0
  36. {python-fasthtml-0.4.0 → python-fasthtml-0.4.1}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-fasthtml
3
- Version: 0.4.0
3
+ Version: 0.4.1
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
@@ -0,0 +1,2 @@
1
+ __version__ = "0.4.1"
2
+ from .core import *
@@ -62,6 +62,7 @@ d = { 'settings': { 'branch': 'main',
62
62
  'fasthtml.core._is_body': ('api/core.html#_is_body', 'fasthtml/core.py'),
63
63
  'fasthtml.core._list': ('api/core.html#_list', 'fasthtml/core.py'),
64
64
  'fasthtml.core._mk_list': ('api/core.html#_mk_list', 'fasthtml/core.py'),
65
+ 'fasthtml.core._mk_locfunc': ('api/core.html#_mk_locfunc', 'fasthtml/core.py'),
65
66
  'fasthtml.core._resp': ('api/core.html#_resp', 'fasthtml/core.py'),
66
67
  'fasthtml.core._send_ws': ('api/core.html#_send_ws', 'fasthtml/core.py'),
67
68
  'fasthtml.core._sig': ('api/core.html#_sig', 'fasthtml/core.py'),
@@ -85,7 +85,7 @@ def File(fname):
85
85
 
86
86
  # %% ../nbs/api/01_components.ipynb
87
87
  def _fill_item(item, obj):
88
- if not isinstance(item,list): return item
88
+ if not isinstance(item,FT): return item
89
89
  tag,cs,attr = item.list
90
90
  if isinstance(cs,tuple): cs = tuple(_fill_item(o, obj) for o in cs)
91
91
  name = attr.get('name', None)
@@ -18,7 +18,7 @@ from datetime import datetime
18
18
  from dataclasses import dataclass,fields,is_dataclass,MISSING,asdict
19
19
  from collections import namedtuple
20
20
  from inspect import isfunction,ismethod,Parameter,get_annotations
21
- from functools import wraps, partialmethod
21
+ from functools import wraps, partialmethod, update_wrapper
22
22
  from http import cookies
23
23
  from urllib.parse import urlencode, parse_qs, quote, unquote
24
24
  from copy import copy,deepcopy
@@ -469,27 +469,38 @@ class FastHTML(Starlette):
469
469
  self.router = RouterX(routes, on_startup=on_startup, on_shutdown=on_shutdown, lifespan=lifespan,
470
470
  hdrs=hdrs, ftrs=ftrs, before=before, after=after, htmlkw=htmlkw, **bodykw)
471
471
 
472
- def route(self, path:str=None, methods=None, name=None, include_in_schema=True):
473
- "Add a route at `path`; the function name is the default method"
474
- pathstr = None if callable(path) else path
475
- def f(func):
476
- n,fn,p = name,func.__name__,pathstr
477
- assert path or (fn not in _verbs), "Must provide a path when using http verb-based function name"
478
- if methods: m = [methods] if isinstance(methods,str) else methods
479
- else: m = [fn] if fn in _verbs else ['get'] if fn=='index' else ['post']
480
- if not n: n = fn
481
- if not p: p = '/'+('' if fn=='index' else fn)
482
- self.router.add_route(p, func, methods=m, name=n, include_in_schema=include_in_schema)
483
- func.__routename__ = n
484
- return func
485
- return f(path) if callable(path) else f
486
-
487
472
  def ws(self, path:str, conn=None, disconn=None, name=None):
488
473
  def f(func):
489
474
  self.router.add_ws(path, func, conn=conn, disconn=disconn, name=name)
490
475
  return func
491
476
  return f
492
477
 
478
+ # %% ../nbs/api/00_core.ipynb
479
+ def _mk_locfunc(f,p):
480
+ class _lf:
481
+ def __init__(self): update_wrapper(self, f)
482
+ def __call__(self, **kw): return p + (f'?{urlencode(kw)}' if kw else '')
483
+ def __str__(self): return p
484
+ return _lf()
485
+
486
+ # %% ../nbs/api/00_core.ipynb
487
+ @patch
488
+ def route(self:FastHTML, path:str=None, methods=None, name=None, include_in_schema=True):
489
+ "Add a route at `path`; the function name is the default method"
490
+ pathstr = None if callable(path) else path
491
+ def f(func):
492
+ n,fn,p = name,func.__name__,pathstr
493
+ assert path or (fn not in _verbs), "Must provide a path when using http verb-based function name"
494
+ if methods: m = [methods] if isinstance(methods,str) else methods
495
+ else: m = [fn] if fn in _verbs else ['get'] if fn=='index' else ['post']
496
+ if not n: n = fn
497
+ if not p: p = '/'+('' if fn=='index' else fn)
498
+ self.router.add_route(p, func, methods=m, name=n, include_in_schema=include_in_schema)
499
+ lf = _mk_locfunc(func, p)
500
+ lf.__routename__ = n
501
+ return lf
502
+ return f(path) if callable(path) else f
503
+
493
504
  all_meths = 'get post put delete patch head trace options'.split()
494
505
  for o in all_meths: setattr(FastHTML, o, partialmethod(FastHTML.route, methods=o))
495
506
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-fasthtml
3
- Version: 0.4.0
3
+ Version: 0.4.1
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
@@ -1,7 +1,7 @@
1
1
  [DEFAULT]
2
2
  repo = fasthtml
3
3
  lib_name = fasthtml
4
- version = 0.4.0
4
+ version = 0.4.1
5
5
  min_python = 3.10
6
6
  license = apache2
7
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
@@ -1,2 +0,0 @@
1
- __version__ = "0.4.0"
2
- from .core import *
File without changes