Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions fasthtml/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ async def _find_p(conn, data, hdrs, arg:str, p:Parameter):
if issubclass(anno, Starlette): return conn.scope['app']
if issubclass(anno, HTTPConnection): return conn
if issubclass(anno, State): return conn.scope['app'].state
if 'session'.startswith(arg.lower()) and anno is dict: return conn.scope.get('session', {})
if anno is dict: return data
if _is_body(anno):
if 'session'.startswith(arg.lower()): return conn.scope.get('session', {})
Expand Down
1 change: 1 addition & 0 deletions nbs/api/00_core.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,7 @@
" if issubclass(anno, Starlette): return conn.scope['app']\n",
" if issubclass(anno, HTTPConnection): return conn\n",
" if issubclass(anno, State): return conn.scope['app'].state\n",
" if 'session'.startswith(arg.lower()) and anno is dict: return conn.scope.get('session', {})\n",
" if anno is dict: return data\n",
" if _is_body(anno):\n",
" if 'session'.startswith(arg.lower()): return conn.scope.get('session', {})\n",
Expand Down
2 changes: 2 additions & 0 deletions tests/test_toaster.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ def test_ft_response():
assert 'Toast FtResponse' in res.text

def test_get_toaster_with_typehint():
cli.get('/set-toast-get', follow_redirects=False)
res = cli.get('/see-toast-with-typehint', follow_redirects=False)
assert 'Toast get' in res.text

cli.get('/set-toast-get', follow_redirects=False)
res = cli.get('/see-toast-with-typehint', follow_redirects=True)
assert 'Toast get' in res.text

Expand Down