|
131 | 131 | { |
132 | 132 | "data": { |
133 | 133 | "text/plain": [ |
134 | | - "datetime.datetime(2024, 12, 14, 14, 0)" |
| 134 | + "datetime.datetime(2024, 12, 20, 14, 0)" |
135 | 135 | ] |
136 | 136 | }, |
137 | 137 | "execution_count": null, |
|
1176 | 1176 | "source": [ |
1177 | 1177 | "#| export\n", |
1178 | 1178 | "htmx_exts = {\n", |
1179 | | - " \"head-support\": \"https://unpkg.com/[email protected].1/head-support.js\", \n", |
1180 | | - " \"preload\": \"https://unpkg.com/htmx-ext-preload@2.0.1/preload.js\", \n", |
1181 | | - " \"class-tools\": \"https://unpkg.com/[email protected]/class-tools.js\", \n", |
1182 | | - " \"loading-states\": \"https://unpkg.com/[email protected]/loading-states.js\", \n", |
1183 | | - " \"multi-swap\": \"https://unpkg.com/[email protected]/multi-swap.js\", \n", |
1184 | | - " \"path-deps\": \"https://unpkg.com/[email protected]/path-deps.js\", \n", |
| 1179 | + " \"head-support\": \"https://unpkg.com/[email protected].3/head-support.js\",\n", |
| 1180 | + " \"preload\": \"https://unpkg.com/htmx-ext-preload@2.1.0/preload.js\",\n", |
| 1181 | + " \"class-tools\": \"https://unpkg.com/[email protected]/class-tools.js\",\n", |
| 1182 | + " \"loading-states\": \"https://unpkg.com/[email protected]/loading-states.js\",\n", |
| 1183 | + " \"multi-swap\": \"https://unpkg.com/[email protected]/multi-swap.js\",\n", |
| 1184 | + " \"path-deps\": \"https://unpkg.com/[email protected]/path-deps.js\",\n", |
1185 | 1185 | " \"remove-me\": \"https://unpkg.com/[email protected]/remove-me.js\",\n", |
1186 | | - " \"ws\": \"https://unpkg.com/[email protected].1/ws.js\",\n", |
| 1186 | + " \"ws\": \"https://unpkg.com/[email protected].2/ws.js\",\n", |
1187 | 1187 | " \"chunked-transfer\": \"https://unpkg.com/[email protected]/transfer-encoding-chunked.js\"\n", |
1188 | 1188 | "}" |
1189 | 1189 | ] |
|
1196 | 1196 | "outputs": [], |
1197 | 1197 | "source": [ |
1198 | 1198 | "#| export\n", |
1199 | | - "htmxsrc = Script(src=\"https://unpkg.com/[email protected].3/dist/htmx.min.js\")\n", |
1200 | | - "fhjsscr = Script(src=\"https://cdn.jsdelivr.net/gh/answerdotai/[email protected].4/fasthtml.js\")\n", |
| 1199 | + "htmxsrc = Script(src=\"https://unpkg.com/[email protected].4/dist/htmx.min.js\")\n", |
| 1200 | + "fhjsscr = Script(src=\"https://cdn.jsdelivr.net/gh/answerdotai/[email protected].12/fasthtml.js\")\n", |
1201 | 1201 | "surrsrc = Script(src=\"https://cdn.jsdelivr.net/gh/answerdotai/surreal@main/surreal.js\")\n", |
1202 | 1202 | "scopesrc = Script(src=\"https://cdn.jsdelivr.net/gh/gnat/css-scope-inline@main/script.js\")\n", |
1203 | 1203 | "viewport = Meta(name=\"viewport\", content=\"width=device-width, initial-scale=1, viewport-fit=cover\")\n", |
|
2478 | 2478 | "name": "stdout", |
2479 | 2479 | "output_type": "stream", |
2480 | 2480 | "text": [ |
2481 | | - "Set to 2024-12-14 12:38:57.886589\n" |
| 2481 | + "Set to 2024-12-20 19:21:33.748637\n" |
2482 | 2482 | ] |
2483 | 2483 | }, |
2484 | 2484 | { |
2485 | 2485 | "data": { |
2486 | 2486 | "text/plain": [ |
2487 | | - "'Session time: 2024-12-14 12:38:57.886589'" |
| 2487 | + "'Session time: 2024-12-20 19:21:33.748637'" |
2488 | 2488 | ] |
2489 | 2489 | }, |
2490 | 2490 | "execution_count": null, |
|
2691 | 2691 | "#| export\n", |
2692 | 2692 | "class APIRouter:\n", |
2693 | 2693 | " \"Add routes to an app\"\n", |
2694 | | - " def __init__(self, prefix:str|None=None): \n", |
| 2694 | + " def __init__(self, prefix:str|None=None, body_wrap=noop_body): \n", |
2695 | 2695 | " self.routes,self.wss = [],[]\n", |
2696 | 2696 | " self.rt_funcs = RouteFuncs() # Store wrapped route function for discoverability\n", |
2697 | 2697 | " self.prefix = prefix if prefix else \"\"\n", |
| 2698 | + " self.body_wrap = body_wrap\n", |
2698 | 2699 | "\n", |
2699 | 2700 | " def _wrap_func(self, func, path=None):\n", |
2700 | 2701 | " name = func.__name__\n", |
|
2704 | 2705 | " if name not in all_meths: setattr(self.rt_funcs, name, wrapped)\n", |
2705 | 2706 | " return wrapped\n", |
2706 | 2707 | "\n", |
2707 | | - " def __call__(self, path:str=None, methods=None, name=None, include_in_schema=True, body_wrap=noop_body):\n", |
| 2708 | + " def __call__(self, path:str=None, methods=None, name=None, include_in_schema=True, body_wrap=None):\n", |
2708 | 2709 | " \"Add a route at `path`\"\n", |
2709 | 2710 | " def f(func):\n", |
2710 | 2711 | " p = self.prefix + (\"/\" + ('' if path.__name__=='index' else func.__name__) if callable(path) else path)\n", |
2711 | 2712 | " wrapped = self._wrap_func(func, p)\n", |
2712 | | - " self.routes.append((func, p, methods, name, include_in_schema, body_wrap))\n", |
| 2713 | + " self.routes.append((func, p, methods, name, include_in_schema, body_wrap or self.body_wrap))\n", |
2713 | 2714 | " return wrapped\n", |
2714 | 2715 | " return f(path) if callable(path) else f\n", |
2715 | 2716 | " \n", |
|
3004 | 3005 | { |
3005 | 3006 | "data": { |
3006 | 3007 | "text/plain": [ |
3007 | | - "'Cookie was set at time 12:38:58.050326'" |
| 3008 | + "'Cookie was set at time 19:21:34.644743'" |
3008 | 3009 | ] |
3009 | 3010 | }, |
3010 | 3011 | "execution_count": null, |
|
0 commit comments