python-fasthtml 0.12.12__tar.gz → 0.12.14__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 (42) hide show
  1. {python_fasthtml-0.12.12/python_fasthtml.egg-info → python_fasthtml-0.12.14}/PKG-INFO +1 -1
  2. python_fasthtml-0.12.14/fasthtml/__init__.py +2 -0
  3. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/fasthtml/_modidx.py +3 -0
  4. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/fasthtml/components.py +14 -7
  5. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/fasthtml/jupyter.py +3 -0
  6. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/fasthtml/oauth.py +23 -7
  7. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14/python_fasthtml.egg-info}/PKG-INFO +1 -1
  8. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/settings.ini +1 -1
  9. python_fasthtml-0.12.12/fasthtml/__init__.py +0 -2
  10. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/CONTRIBUTING.md +0 -0
  11. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/LICENSE +0 -0
  12. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/MANIFEST.in +0 -0
  13. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/README.md +0 -0
  14. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/fasthtml/authmw.py +0 -0
  15. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/fasthtml/basics.py +0 -0
  16. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/fasthtml/cli.py +0 -0
  17. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/fasthtml/common.py +0 -0
  18. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/fasthtml/components.pyi +0 -0
  19. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/fasthtml/core.py +0 -0
  20. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/fasthtml/core.pyi +0 -0
  21. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/fasthtml/fastapp.py +0 -0
  22. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/fasthtml/ft.py +0 -0
  23. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/fasthtml/js.py +0 -0
  24. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/fasthtml/katex.js +0 -0
  25. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/fasthtml/live_reload.py +0 -0
  26. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/fasthtml/pico.py +0 -0
  27. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/fasthtml/starlette.py +0 -0
  28. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/fasthtml/stripe_otp.py +0 -0
  29. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/fasthtml/svg.py +0 -0
  30. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/fasthtml/toaster.py +0 -0
  31. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/fasthtml/xtend.py +0 -0
  32. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/fasthtml/xtend.pyi +0 -0
  33. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/pyproject.toml +0 -0
  34. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/python_fasthtml.egg-info/SOURCES.txt +0 -0
  35. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/python_fasthtml.egg-info/dependency_links.txt +0 -0
  36. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/python_fasthtml.egg-info/entry_points.txt +0 -0
  37. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/python_fasthtml.egg-info/not-zip-safe +0 -0
  38. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/python_fasthtml.egg-info/requires.txt +0 -0
  39. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/python_fasthtml.egg-info/top_level.txt +0 -0
  40. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/setup.cfg +0 -0
  41. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/setup.py +0 -0
  42. {python_fasthtml-0.12.12 → python_fasthtml-0.12.14}/tests/test_toaster.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-fasthtml
3
- Version: 0.12.12
3
+ Version: 0.12.14
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 and contributors
@@ -0,0 +1,2 @@
1
+ __version__ = "0.12.14"
2
+ from .core import *
@@ -132,6 +132,7 @@ d = { 'settings': { 'branch': 'main',
132
132
  'fasthtml.jupyter.JupyUvi': ('api/jupyter.html#jupyuvi', 'fasthtml/jupyter.py'),
133
133
  'fasthtml.jupyter.JupyUvi.__init__': ('api/jupyter.html#jupyuvi.__init__', 'fasthtml/jupyter.py'),
134
134
  'fasthtml.jupyter.JupyUvi.start': ('api/jupyter.html#jupyuvi.start', 'fasthtml/jupyter.py'),
135
+ 'fasthtml.jupyter.JupyUvi.start_async': ('api/jupyter.html#jupyuvi.start_async', 'fasthtml/jupyter.py'),
135
136
  'fasthtml.jupyter.JupyUvi.stop': ('api/jupyter.html#jupyuvi.stop', 'fasthtml/jupyter.py'),
136
137
  'fasthtml.jupyter.JupyUviAsync': ('api/jupyter.html#jupyuviasync', 'fasthtml/jupyter.py'),
137
138
  'fasthtml.jupyter.JupyUviAsync.__init__': ( 'api/jupyter.html#jupyuviasync.__init__',
@@ -166,6 +167,8 @@ d = { 'settings': { 'branch': 'main',
166
167
  'fasthtml.oauth.GitHubAppClient.__init__': ('api/oauth.html#githubappclient.__init__', 'fasthtml/oauth.py'),
167
168
  'fasthtml.oauth.GoogleAppClient': ('api/oauth.html#googleappclient', 'fasthtml/oauth.py'),
168
169
  'fasthtml.oauth.GoogleAppClient.__init__': ('api/oauth.html#googleappclient.__init__', 'fasthtml/oauth.py'),
170
+ 'fasthtml.oauth.GoogleAppClient.consent_url': ( 'api/oauth.html#googleappclient.consent_url',
171
+ 'fasthtml/oauth.py'),
169
172
  'fasthtml.oauth.GoogleAppClient.creds': ('api/oauth.html#googleappclient.creds', 'fasthtml/oauth.py'),
170
173
  'fasthtml.oauth.GoogleAppClient.from_file': ( 'api/oauth.html#googleappclient.from_file',
171
174
  'fasthtml/oauth.py'),
@@ -3,7 +3,7 @@
3
3
  # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/api/01_components.ipynb.
4
4
 
5
5
  # %% auto 0
6
- __all__ = ['named', 'html_attrs', 'hx_attrs', 'hx_attrs_annotations', 'show', 'attrmap_x', 'ft_html', 'ft_hx', 'File',
6
+ __all__ = ['named', 'html_attrs', 'hx_attrs', 'hx_attrs_annotations', 'attrmap_x', 'ft_html', 'ft_hx', 'File', 'show',
7
7
  'fill_form', 'fill_dataclass', 'find_inputs', 'html2ft', 'sse_message', 'A', 'Abbr', 'Address', 'Area',
8
8
  'Article', 'Aside', 'Audio', 'B', 'Base', 'Bdi', 'Bdo', 'Blockquote', 'Body', 'Br', 'Button', 'Canvas',
9
9
  'Caption', 'Cite', 'Code', 'Col', 'Colgroup', 'Data', 'Datalist', 'Dd', 'Del', 'Details', 'Dfn', 'Dialog',
@@ -31,12 +31,6 @@ import types, json
31
31
  try: from IPython import display
32
32
  except ImportError: display=None
33
33
 
34
- # %% ../nbs/api/01_components.ipynb
35
- def show(ft,*rest):
36
- "Renders FT Components into HTML within a Jupyter notebook."
37
- if rest: ft = (ft,)+rest
38
- display.display(display.HTML(to_xml(ft)))
39
-
40
34
  # %% ../nbs/api/01_components.ipynb
41
35
  @patch
42
36
  def __str__(self:FT): return self.id if self.id else object.__str__(self)
@@ -122,6 +116,19 @@ def File(fname):
122
116
  "Use the unescaped text in file `fname` directly"
123
117
  return NotStr(Path(fname).read_text())
124
118
 
119
+ # %% ../nbs/api/01_components.ipynb
120
+ def show(ft, *rest, iframe=False, height='auto', style=None):
121
+ "Renders FT Components into HTML within a Jupyter notebook."
122
+ if rest: ft = (ft,)+rest
123
+ res = to_xml(ft)
124
+ if iframe:
125
+ style = "border: none; " + (style or "")
126
+ cfg = dict(frameborder=0, width='100%', height=height, style=style)
127
+ res = to_xml(Iframe(srcdoc=res, **cfg))
128
+ with warnings.catch_warnings():
129
+ warnings.simplefilter("ignore", UserWarning)
130
+ display.display(display.HTML(res))
131
+
125
132
  # %% ../nbs/api/01_components.ipynb
126
133
  def _fill_item(item, obj):
127
134
  if not isinstance(item,FT): return item
@@ -88,6 +88,9 @@ class JupyUvi:
88
88
  def start(self):
89
89
  self.server = nb_serve(self.app, log_level=self.log_level, host=self.host, port=self.port, **self.kwargs)
90
90
 
91
+ async def start_async(self):
92
+ self.server = await nb_serve_async(self.app, log_level=self.log_level, host=self.host, port=self.port, **self.kwargs)
93
+
91
94
  def stop(self):
92
95
  self.server.should_exit = True
93
96
  wait_port_free(self.port)
@@ -26,15 +26,17 @@ class GoogleAppClient(_AppClient):
26
26
  token_url = "https://oauth2.googleapis.com/token"
27
27
  info_url = "https://openidconnect.googleapis.com/v1/userinfo"
28
28
 
29
- def __init__(self, client_id, client_secret, code=None, scope=None, **kwargs):
29
+ def __init__(self, client_id, client_secret, code=None, scope=None, project_id=None, **kwargs):
30
30
  scope_pre = "https://www.googleapis.com/auth/userinfo"
31
31
  if not scope: scope=["openid", f"{scope_pre}.email", f"{scope_pre}.profile"]
32
32
  super().__init__(client_id, client_secret, code=code, scope=scope, **kwargs)
33
+ self.project_id = project_id
33
34
 
34
35
  @classmethod
35
36
  def from_file(cls, fname, code=None, scope=None, **kwargs):
36
37
  cred = Path(fname).read_json()['web']
37
- return cls(cred['client_id'], client_secret=cred['client_secret'], code=code, scope=scope, **kwargs)
38
+ return cls(cred['client_id'], client_secret=cred['client_secret'], project_id=cred['project_id'],
39
+ code=code, scope=scope, **kwargs)
38
40
 
39
41
  # %% ../nbs/api/08_oauth.ipynb
40
42
  class GitHubAppClient(_AppClient):
@@ -67,6 +69,7 @@ class DiscordAppClient(_AppClient):
67
69
  base_url = "https://discord.com/oauth2/authorize"
68
70
  token_url = "https://discord.com/api/oauth2/token"
69
71
  revoke_url = "https://discord.com/api/oauth2/token/revoke"
72
+ info_url = "https://discord.com/api/users/@me"
70
73
  id_key = 'id'
71
74
 
72
75
  def __init__(self, client_id, client_secret, is_user=False, perms=0, scope=None, **kwargs):
@@ -75,14 +78,18 @@ class DiscordAppClient(_AppClient):
75
78
  self.perms = perms
76
79
  super().__init__(client_id, client_secret, scope=scope, **kwargs)
77
80
 
78
- def login_link(self):
81
+ def login_link(self, redirect_uri=None, scope=None, state=None):
82
+ use_scope = scope or self.scope
79
83
  d = dict(response_type='code', client_id=self.client_id,
80
- integration_type=self.integration_type, scope=self.scope) #, permissions=self.perms, prompt='consent')
84
+ integration_type=self.integration_type, scope=use_scope)
85
+ if state: d['state'] = state
86
+ if redirect_uri: d['redirect_uri'] = redirect_uri
81
87
  return f'{self.base_url}?' + urlencode(d)
82
88
 
83
- def parse_response(self, code):
89
+ def parse_response(self, code, redirect_uri=None):
84
90
  headers = {'Content-Type': 'application/x-www-form-urlencoded'}
85
- data = dict(grant_type='authorization_code', code=code)#, redirect_uri=self.redirect_uri)
91
+ data = dict(grant_type='authorization_code', code=code)
92
+ if redirect_uri: data['redirect_uri'] = redirect_uri
86
93
  r = httpx.post(self.token_url, data=data, headers=headers, auth=(self.client_id, self.client_secret))
87
94
  r.raise_for_status()
88
95
  self.parse_request_body_response(r.text)
@@ -161,7 +168,8 @@ class OAuth:
161
168
  if not skip: skip = [redir_path,error_path,login_path]
162
169
  store_attr()
163
170
  def before(req, session):
164
- auth = req.scope['auth'] = session.get('auth')
171
+ if 'auth' not in req.scope: req.scope['auth'] = session.get('auth')
172
+ auth = req.scope['auth']
165
173
  if not auth: return self.redir_login(session)
166
174
  res = self.check_invalid(req, session, auth)
167
175
  if res: return res
@@ -203,6 +211,14 @@ except ImportError:
203
211
  Request=None
204
212
  class Credentials: pass
205
213
 
214
+ # %% ../nbs/api/08_oauth.ipynb
215
+ @patch()
216
+ def consent_url(self:GoogleAppClient, proj=None):
217
+ "Get Google OAuth consent screen URL"
218
+ loc = "https://console.cloud.google.com/auth/clients"
219
+ if proj is None: proj=self.project_id
220
+ return f"{loc}/{self.client_id}?project={proj}"
221
+
206
222
  # %% ../nbs/api/08_oauth.ipynb
207
223
  @patch
208
224
  def update(self:Credentials):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-fasthtml
3
- Version: 0.12.12
3
+ Version: 0.12.14
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 and contributors
@@ -1,7 +1,7 @@
1
1
  [DEFAULT]
2
2
  repo = fasthtml
3
3
  lib_name = python-fasthtml
4
- version = 0.12.12
4
+ version = 0.12.14
5
5
  min_python = 3.10
6
6
  license = apache2
7
7
  requirements = fastcore>=1.8.1 python-dateutil starlette>0.33 oauthlib itsdangerous uvicorn[standard]>=0.30 httpx fastlite>=0.1.1 python-multipart beautifulsoup4
@@ -1,2 +0,0 @@
1
- __version__ = "0.12.12"
2
- from .core import *