python-fasthtml 0.0.5__tar.gz → 0.0.7__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.0.5/python_fasthtml.egg-info → python-fasthtml-0.0.7}/PKG-INFO +2 -1
- {python-fasthtml-0.0.5 → python-fasthtml-0.0.7}/fasthtml/__init__.py +2 -2
- {python-fasthtml-0.0.5 → python-fasthtml-0.0.7}/fasthtml/_modidx.py +1 -1
- {python-fasthtml-0.0.5 → python-fasthtml-0.0.7}/fasthtml/core.py +22 -12
- {python-fasthtml-0.0.5 → python-fasthtml-0.0.7/python_fasthtml.egg-info}/PKG-INFO +2 -1
- {python-fasthtml-0.0.5 → python-fasthtml-0.0.7}/python_fasthtml.egg-info/SOURCES.txt +1 -1
- {python-fasthtml-0.0.5 → python-fasthtml-0.0.7}/python_fasthtml.egg-info/requires.txt +1 -0
- {python-fasthtml-0.0.5 → python-fasthtml-0.0.7}/settings.ini +2 -2
- {python-fasthtml-0.0.5 → python-fasthtml-0.0.7}/LICENSE +0 -0
- {python-fasthtml-0.0.5 → python-fasthtml-0.0.7}/MANIFEST.in +0 -0
- {python-fasthtml-0.0.5 → python-fasthtml-0.0.7}/README.md +0 -0
- {python-fasthtml-0.0.5 → python-fasthtml-0.0.7}/fasthtml/all.py +0 -0
- /python-fasthtml-0.0.5/fasthtml/auth.py → /python-fasthtml-0.0.7/fasthtml/authmw.py +0 -0
- {python-fasthtml-0.0.5 → python-fasthtml-0.0.7}/fasthtml/components.py +0 -0
- {python-fasthtml-0.0.5 → python-fasthtml-0.0.7}/fasthtml/fastapp.py +0 -0
- {python-fasthtml-0.0.5 → python-fasthtml-0.0.7}/fasthtml/oauth.py +0 -0
- {python-fasthtml-0.0.5 → python-fasthtml-0.0.7}/fasthtml/starlette.py +0 -0
- {python-fasthtml-0.0.5 → python-fasthtml-0.0.7}/fasthtml/xtend.py +0 -0
- {python-fasthtml-0.0.5 → python-fasthtml-0.0.7}/python_fasthtml.egg-info/dependency_links.txt +0 -0
- {python-fasthtml-0.0.5 → python-fasthtml-0.0.7}/python_fasthtml.egg-info/entry_points.txt +0 -0
- {python-fasthtml-0.0.5 → python-fasthtml-0.0.7}/python_fasthtml.egg-info/not-zip-safe +0 -0
- {python-fasthtml-0.0.5 → python-fasthtml-0.0.7}/python_fasthtml.egg-info/top_level.txt +0 -0
- {python-fasthtml-0.0.5 → python-fasthtml-0.0.7}/setup.cfg +0 -0
- {python-fasthtml-0.0.5 → python-fasthtml-0.0.7}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: python-fasthtml
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.7
|
|
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
|
|
@@ -23,6 +23,7 @@ Requires-Dist: itsdangerous
|
|
|
23
23
|
Requires-Dist: uvicorn
|
|
24
24
|
Requires-Dist: httpx
|
|
25
25
|
Requires-Dist: fastlite
|
|
26
|
+
Requires-Dist: python-multipart
|
|
26
27
|
Provides-Extra: dev
|
|
27
28
|
Requires-Dist: ipython; extra == "dev"
|
|
28
29
|
Requires-Dist: lxml; extra == "dev"
|
|
@@ -6,7 +6,7 @@ d = { 'settings': { 'branch': 'main',
|
|
|
6
6
|
'git_url': 'https://github.com/AnswerDotAI/fasthtml',
|
|
7
7
|
'lib_path': 'fasthtml'},
|
|
8
8
|
'syms': { 'fasthtml.all': {},
|
|
9
|
-
'fasthtml.
|
|
9
|
+
'fasthtml.authmw': {},
|
|
10
10
|
'fasthtml.components': { 'fasthtml.components._FindElems': ('components.html#_findelems', 'fasthtml/components.py'),
|
|
11
11
|
'fasthtml.components._FindElems.__init__': ( 'components.html#_findelems.__init__',
|
|
12
12
|
'fasthtml/components.py'),
|
|
@@ -144,35 +144,42 @@ def _wrap_resp(req, resp, cls, hdrs, **bodykw):
|
|
|
144
144
|
cls = HTMLResponse
|
|
145
145
|
return cls(resp)
|
|
146
146
|
|
|
147
|
-
def _wrap_ep(f, hdrs, **bodykw):
|
|
147
|
+
def _wrap_ep(f, hdrs, before, **bodykw):
|
|
148
148
|
if not (isfunction(f) or ismethod(f)): return f
|
|
149
149
|
sig = signature(f)
|
|
150
150
|
params = sig.parameters
|
|
151
151
|
cls = sig.return_annotation
|
|
152
152
|
|
|
153
153
|
async def _f(req):
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
154
|
+
resp = None
|
|
155
|
+
for b in before:
|
|
156
|
+
if not resp:
|
|
157
|
+
wreq = await _wrap_req(req, signature(b).parameters)
|
|
158
|
+
resp = b(*wreq)
|
|
159
|
+
if is_async_callable(b): resp = await resp
|
|
160
|
+
if not resp:
|
|
161
|
+
wreq = await _wrap_req(req, params)
|
|
162
|
+
resp = f(*wreq)
|
|
163
|
+
if is_async_callable(f): resp = await resp
|
|
157
164
|
return _wrap_resp(req, resp, cls, hdrs, **bodykw)
|
|
158
165
|
return _f
|
|
159
166
|
|
|
160
167
|
class RouteX(Route):
|
|
161
168
|
def __init__(self, path:str, endpoint, *, methods=None, name=None, include_in_schema=True, middleware=None,
|
|
162
|
-
hdrs=None, **bodykw):
|
|
163
|
-
super().__init__(path, _wrap_ep(endpoint, hdrs, **bodykw), methods=methods, name=name,
|
|
169
|
+
hdrs=None, before=None, **bodykw):
|
|
170
|
+
super().__init__(path, _wrap_ep(endpoint, hdrs, before, **bodykw), methods=methods, name=name,
|
|
164
171
|
include_in_schema=include_in_schema, middleware=middleware)
|
|
165
172
|
|
|
166
173
|
class RouterX(Router):
|
|
167
174
|
def __init__(self, routes=None, redirect_slashes=True, default=None, on_startup=None, on_shutdown=None,
|
|
168
|
-
lifespan=None, *, middleware=None, hdrs=None, **bodykw):
|
|
175
|
+
lifespan=None, *, middleware=None, hdrs=None, before=None, **bodykw):
|
|
169
176
|
super().__init__(routes, redirect_slashes, default, on_startup, on_shutdown,
|
|
170
177
|
lifespan=lifespan, middleware=middleware)
|
|
171
|
-
self.hdrs,self.bodykw = hdrs or (),bodykw
|
|
178
|
+
self.hdrs,self.bodykw,self.before = hdrs or (),bodykw,before or ()
|
|
172
179
|
|
|
173
180
|
def add_route( self, path: str, endpoint: callable, methods=None, name=None, include_in_schema=True):
|
|
174
181
|
route = RouteX(path, endpoint=endpoint, methods=methods, name=name, include_in_schema=include_in_schema,
|
|
175
|
-
hdrs=self.hdrs, **self.bodykw)
|
|
182
|
+
hdrs=self.hdrs, before=self.before, **self.bodykw)
|
|
176
183
|
self.routes = [o for o in self.routes if o.methods!=methods or o.path!=path]
|
|
177
184
|
self.routes.append(route)
|
|
178
185
|
|
|
@@ -188,12 +195,14 @@ def get_key(key=None, fname='.sesskey'):
|
|
|
188
195
|
fname.write_text(key)
|
|
189
196
|
return key
|
|
190
197
|
|
|
198
|
+
def _list(o): return [] if not o else o if isinstance(o, (tuple,list)) else [o]
|
|
199
|
+
|
|
191
200
|
class FastHTML(Starlette):
|
|
192
201
|
def __init__(self, debug=False, routes=None, middleware=None, exception_handlers=None,
|
|
193
|
-
on_startup=None, on_shutdown=None, lifespan=None, hdrs=None,
|
|
202
|
+
on_startup=None, on_shutdown=None, lifespan=None, hdrs=None, before=None,
|
|
194
203
|
secret_key=None, session_cookie='session_', max_age=365*24*3600, sess_path='/',
|
|
195
204
|
same_site='lax', sess_https_only=False, sess_domain=None, key_fname='.sesskey', **bodykw):
|
|
196
|
-
|
|
205
|
+
middleware,before = _list(middleware),_list(before)
|
|
197
206
|
secret_key = get_key(secret_key, key_fname)
|
|
198
207
|
sess = Middleware(SessionMiddleware, secret_key=secret_key, session_cookie=session_cookie,
|
|
199
208
|
max_age=max_age, path=sess_path, same_site=same_site,
|
|
@@ -201,7 +210,8 @@ class FastHTML(Starlette):
|
|
|
201
210
|
middleware.append(sess)
|
|
202
211
|
super().__init__(debug, routes, middleware, exception_handlers, on_startup, on_shutdown, lifespan=lifespan)
|
|
203
212
|
hdrs = list([] if hdrs is None else hdrs) + [htmxscr]
|
|
204
|
-
self.router = RouterX(routes, on_startup=on_startup, on_shutdown=on_shutdown, lifespan=lifespan, hdrs=hdrs,
|
|
213
|
+
self.router = RouterX(routes, on_startup=on_startup, on_shutdown=on_shutdown, lifespan=lifespan, hdrs=hdrs,
|
|
214
|
+
before=before, **bodykw)
|
|
205
215
|
|
|
206
216
|
def route(self, path:str, methods=None, name=None, include_in_schema=True):
|
|
207
217
|
def f(func):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: python-fasthtml
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.7
|
|
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
|
|
@@ -23,6 +23,7 @@ Requires-Dist: itsdangerous
|
|
|
23
23
|
Requires-Dist: uvicorn
|
|
24
24
|
Requires-Dist: httpx
|
|
25
25
|
Requires-Dist: fastlite
|
|
26
|
+
Requires-Dist: python-multipart
|
|
26
27
|
Provides-Extra: dev
|
|
27
28
|
Requires-Dist: ipython; extra == "dev"
|
|
28
29
|
Requires-Dist: lxml; extra == "dev"
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
[DEFAULT]
|
|
2
2
|
repo = fasthtml
|
|
3
3
|
lib_name = fasthtml
|
|
4
|
-
version = 0.0.
|
|
4
|
+
version = 0.0.7
|
|
5
5
|
min_python = 3.10
|
|
6
6
|
license = apache2
|
|
7
|
-
requirements = fastcore python-dateutil starlette oauthlib itsdangerous uvicorn httpx fastlite
|
|
7
|
+
requirements = fastcore python-dateutil starlette oauthlib itsdangerous uvicorn httpx fastlite python-multipart
|
|
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
|
{python-fasthtml-0.0.5 → python-fasthtml-0.0.7}/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
|