python-fasthtml 0.12.41__tar.gz → 0.12.42__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.12.41/python_fasthtml.egg-info → python_fasthtml-0.12.42}/PKG-INFO +1 -1
- python_fasthtml-0.12.42/fasthtml/__init__.py +2 -0
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/fasthtml/core.py +9 -8
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/fasthtml/oauth.py +10 -4
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42/python_fasthtml.egg-info}/PKG-INFO +1 -1
- python_fasthtml-0.12.41/fasthtml/__init__.py +0 -2
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/CONTRIBUTING.md +0 -0
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/LICENSE +0 -0
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/MANIFEST.in +0 -0
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/README.md +0 -0
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/fasthtml/_modidx.py +0 -0
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/fasthtml/authmw.py +0 -0
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/fasthtml/basics.py +0 -0
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/fasthtml/cli.py +0 -0
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/fasthtml/common.py +0 -0
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/fasthtml/components.py +0 -0
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/fasthtml/components.pyi +0 -0
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/fasthtml/core.pyi +0 -0
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/fasthtml/fastapp.py +0 -0
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/fasthtml/ft.py +0 -0
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/fasthtml/js.py +0 -0
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/fasthtml/jupyter.py +0 -0
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/fasthtml/katex.js +0 -0
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/fasthtml/live_reload.py +0 -0
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/fasthtml/pico.py +0 -0
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/fasthtml/starlette.py +0 -0
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/fasthtml/stripe_otp.py +0 -0
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/fasthtml/svg.py +0 -0
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/fasthtml/toaster.py +0 -0
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/fasthtml/xtend.py +0 -0
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/fasthtml/xtend.pyi +0 -0
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/pyproject.toml +0 -0
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/python_fasthtml.egg-info/SOURCES.txt +0 -0
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/python_fasthtml.egg-info/dependency_links.txt +0 -0
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/python_fasthtml.egg-info/entry_points.txt +0 -0
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/python_fasthtml.egg-info/requires.txt +0 -0
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/python_fasthtml.egg-info/top_level.txt +0 -0
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/setup.cfg +0 -0
- {python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/tests/test_toaster.py +0 -0
|
@@ -12,11 +12,12 @@ __all__ = ['empty', 'htmx_hdrs', 'fh_cfg', 'htmx_resps', 'htmx_exts', 'htmxsrc',
|
|
|
12
12
|
'unqid']
|
|
13
13
|
|
|
14
14
|
# %% ../nbs/api/00_core.ipynb #23503b9e
|
|
15
|
-
import json,uuid,inspect,types,signal,asyncio,threading,inspect,random,contextlib,httpx,itsdangerous
|
|
15
|
+
import json,uuid,inspect,types,signal,asyncio,threading,inspect,random,contextlib,httpx,itsdangerous,uvicorn
|
|
16
16
|
|
|
17
17
|
from fastcore.utils import *
|
|
18
18
|
from fastcore.xml import *
|
|
19
|
-
from fastcore.meta import use_kwargs_dict
|
|
19
|
+
from fastcore.meta import use_kwargs_dict,delegates
|
|
20
|
+
from fastcore.style import S
|
|
20
21
|
|
|
21
22
|
from types import UnionType, SimpleNamespace as ns, GenericAlias
|
|
22
23
|
from typing import Optional, get_type_hints, get_args, get_origin, Union, Mapping, TypedDict, List, Any
|
|
@@ -702,15 +703,15 @@ def set_lifespan(self:FastHTML, value):
|
|
|
702
703
|
self.router.lifespan_context = value
|
|
703
704
|
|
|
704
705
|
# %% ../nbs/api/00_core.ipynb #3a348474
|
|
706
|
+
@delegates(uvicorn.run)
|
|
705
707
|
def serve(
|
|
706
708
|
appname=None, # Name of the module
|
|
707
709
|
app='app', # App instance to be served
|
|
708
710
|
host='0.0.0.0', # If host is 0.0.0.0 will convert to localhost
|
|
709
711
|
port=None, # If port is None it will default to 5001 or the PORT environment variable
|
|
710
712
|
reload=True, # Default is to reload the app upon code changes
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
):
|
|
713
|
+
**kwargs
|
|
714
|
+
):
|
|
714
715
|
"Run the app in an async server, with live reload set as the default."
|
|
715
716
|
bk = inspect.currentframe().f_back
|
|
716
717
|
glb = bk.f_globals
|
|
@@ -718,11 +719,11 @@ def serve(
|
|
|
718
719
|
if not appname:
|
|
719
720
|
if glb.get('__name__')=='__main__': appname = Path(glb.get('__file__', '')).stem
|
|
720
721
|
elif code.co_name=='main' and bk.f_back.f_globals.get('__name__')=='__main__': appname = inspect.getmodule(bk).__name__
|
|
721
|
-
import uvicorn
|
|
722
722
|
if appname:
|
|
723
723
|
if not port: port=int(os.getenv("PORT", default=5001))
|
|
724
|
-
|
|
725
|
-
|
|
724
|
+
link = f'http://{"localhost" if host=="0.0.0.0" else host}:{port}'
|
|
725
|
+
print('Link: '+ S.light_red.bold(link))
|
|
726
|
+
uvicorn.run(f'{appname}:{app}', host=host, port=port, reload=reload, **kwargs)
|
|
726
727
|
|
|
727
728
|
# %% ../nbs/api/00_core.ipynb #8121968a
|
|
728
729
|
class Client:
|
|
@@ -3,14 +3,17 @@
|
|
|
3
3
|
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/api/08_oauth.ipynb.
|
|
4
4
|
|
|
5
5
|
# %% auto #0
|
|
6
|
-
__all__ = ['http_patterns', 'GoogleAppClient', 'GitHubAppClient', 'HuggingFaceClient', 'DiscordAppClient',
|
|
7
|
-
'AppleAppClient', 'get_host', 'redir_url', 'url_match', 'OAuth', 'load_creds']
|
|
6
|
+
__all__ = ['log', 'http_patterns', 'GoogleAppClient', 'GitHubAppClient', 'HuggingFaceClient', 'DiscordAppClient',
|
|
7
|
+
'Auth0AppClient', 'AppleAppClient', 'get_host', 'redir_url', 'url_match', 'OAuth', 'load_creds']
|
|
8
8
|
|
|
9
9
|
# %% ../nbs/api/08_oauth.ipynb #793722f2
|
|
10
10
|
from .common import *
|
|
11
11
|
from oauthlib.oauth2 import WebApplicationClient
|
|
12
12
|
from urllib.parse import urlparse, urlencode, parse_qs, quote, unquote
|
|
13
|
-
import secrets, httpx, time, asyncio
|
|
13
|
+
import secrets, httpx, time, asyncio, logging
|
|
14
|
+
|
|
15
|
+
# %% ../nbs/api/08_oauth.ipynb #44aa4a88
|
|
16
|
+
log = logging.getLogger(__name__)
|
|
14
17
|
|
|
15
18
|
# %% ../nbs/api/08_oauth.ipynb #0a078133
|
|
16
19
|
class _AppClient(WebApplicationClient):
|
|
@@ -186,8 +189,11 @@ async def parse_response_async(self:_AppClient, code, redirect_uri):
|
|
|
186
189
|
"Get the token from the oauth2 server response"
|
|
187
190
|
payload = dict(code=code, redirect_uri=redirect_uri, client_id=self.client_id,
|
|
188
191
|
client_secret=self.client_secret, grant_type='authorization_code')
|
|
192
|
+
log.debug(f"OAuth token request: redirect_uri={redirect_uri}, code={code[:20]}...")
|
|
189
193
|
async with httpx.AsyncClient() as c:
|
|
190
|
-
r = (await c.post(self.token_url, data=payload))
|
|
194
|
+
r = (await c.post(self.token_url, data=payload))
|
|
195
|
+
log.debug(f"OAuth response: {r.status_code} - {r.text}")
|
|
196
|
+
r.raise_for_status()
|
|
191
197
|
self.parse_request_body_response(r.text)
|
|
192
198
|
|
|
193
199
|
@patch
|
|
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
|
|
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.12.41 → python_fasthtml-0.12.42}/python_fasthtml.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{python_fasthtml-0.12.41 → python_fasthtml-0.12.42}/python_fasthtml.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|