|
177 | 177 | {
|
178 | 178 | "data": {
|
179 | 179 | "text/plain": [
|
180 |
| - "datetime.datetime(2024, 8, 14, 14, 0)" |
| 180 | + "datetime.datetime(2024, 8, 15, 14, 0)" |
181 | 181 | ]
|
182 | 182 | },
|
183 | 183 | "execution_count": null,
|
|
640 | 640 | "source": [
|
641 | 641 | "#| export\n",
|
642 | 642 | "def flat_xt(lst):\n",
|
643 |
| - " \"Flatten lists, except for `FT`s\"\n", |
| 643 | + " \"Flatten lists\"\n", |
644 | 644 | " result = []\n",
|
645 | 645 | " if isinstance(lst,(FT,str)): lst=[lst]\n",
|
646 | 646 | " for item in lst:\n",
|
647 |
| - " if isinstance(item, (list,tuple)) and not isinstance(item, FT): result.extend(item)\n", |
| 647 | + " if isinstance(item, (list,tuple)): result.extend(item)\n", |
648 | 648 | " else: result.append(item)\n",
|
649 | 649 | " return result"
|
650 | 650 | ]
|
|
737 | 737 | "#| export\n",
|
738 | 738 | "async def _send_ws(ws, resp):\n",
|
739 | 739 | " if not resp: return\n",
|
740 |
| - " res = to_xml(resp, indent=fh_cfg.indent) if isinstance(resp, (list,tuple)) or hasattr(resp, '__ft__') else resp\n", |
| 740 | + " res = to_xml(resp, indent=fh_cfg.indent) if isinstance(resp, (list,tuple,FT)) or hasattr(resp, '__ft__') else resp\n", |
741 | 741 | " await ws.send_text(res)\n",
|
742 | 742 | "\n",
|
743 | 743 | "def _ws_endp(recv, conn=None, disconn=None, hdrs=None, before=None):\n",
|
|
898 | 898 | "def _apply_ft(o):\n",
|
899 | 899 | " if isinstance(o, tuple): o = tuple(_apply_ft(c) for c in o)\n",
|
900 | 900 | " if hasattr(o, '__ft__'): o = o.__ft__()\n",
|
901 |
| - " if isinstance(o, FT): o[1] = [_apply_ft(c) for c in o[1]]\n", |
| 901 | + " if isinstance(o, FT): o.children = [_apply_ft(c) for c in o.children]\n", |
902 | 902 | " return o\n",
|
903 | 903 | "\n",
|
904 | 904 | "def _to_xml(req, resp, indent):\n",
|
|
942 | 942 | " if isinstance(resp, FileResponse) and not os.path.exists(resp.path): raise HTTPException(404, resp.path)\n",
|
943 | 943 | " if isinstance(resp, Response): return resp\n",
|
944 | 944 | " if cls is not empty: return cls(resp)\n",
|
945 |
| - " if isinstance(resp, (list,tuple,HttpHeader)) or hasattr(resp, '__ft__'): return _xt_resp(req, resp)\n", |
| 945 | + " if isinstance(resp, (list,tuple,HttpHeader,FT)) or hasattr(resp, '__ft__'): return _xt_resp(req, resp)\n", |
946 | 946 | " if isinstance(resp, str): cls = HTMLResponse\n",
|
947 | 947 | " elif isinstance(resp, Mapping): cls = JSONResponse\n",
|
948 | 948 | " else:\n",
|
|
1431 | 1431 | "text": [
|
1432 | 1432 | "<!doctype html>\n",
|
1433 | 1433 | "\n",
|
1434 |
| - "<html>\n", |
1435 |
| - " <div hx-post=\"/yoyo\">Text.</div>\n", |
| 1434 | + "<html><div hx-post=\"/yoyo\">Text.</div>\n", |
1436 | 1435 | "</html>\n",
|
1437 | 1436 | "\n"
|
1438 | 1437 | ]
|
|
1456 | 1455 | "text": [
|
1457 | 1456 | "<!doctype html>\n",
|
1458 | 1457 | "\n",
|
1459 |
| - "<html>\n", |
1460 |
| - " <body>\n", |
1461 |
| - " <div class=\"px-2\" hx-post=\"/hostie?a=b\">Text.</div>\n", |
1462 |
| - " </body>\n", |
| 1458 | + "<html><body><div class=\"px-2\" hx-post=\"/hostie?a=b\">Text.</div>\n", |
| 1459 | + "</body>\n", |
1463 | 1460 | "</html>\n",
|
1464 | 1461 | "\n"
|
1465 | 1462 | ]
|
|
1483 | 1480 | "text": [
|
1484 | 1481 | "<!doctype html>\n",
|
1485 | 1482 | "\n",
|
1486 |
| - "<html>\n", |
1487 |
| - " <div hx-get=\"/hostie\">Text.</div>\n", |
| 1483 | + "<html><div hx-get=\"/hostie\">Text.</div>\n", |
1488 | 1484 | "</html>\n",
|
1489 | 1485 | "\n"
|
1490 | 1486 | ]
|
|
1531 | 1527 | "text": [
|
1532 | 1528 | "<!doctype html>\n",
|
1533 | 1529 | "\n",
|
1534 |
| - "<html>\n", |
1535 |
| - " <div href=\"/user/Alexis\">Text.</div>\n", |
| 1530 | + "<html><div href=\"/user/Alexis\">Text.</div>\n", |
1536 | 1531 | "</html>\n",
|
1537 | 1532 | "\n"
|
1538 | 1533 | ]
|
|
1668 | 1663 | "metadata": {},
|
1669 | 1664 | "outputs": [],
|
1670 | 1665 | "source": [
|
1671 |
| - "test_r(cli, '/html/1', '<body>\\n <h4>Next is 2.</h4>\\n</body>\\n', hx=True)\n", |
| 1666 | + "test_r(cli, '/html/1', '<body><h4>Next is 2.</h4>\\n</body>\\n', hx=True)\n", |
1672 | 1667 | "test_r(cli, '/static/foo/jph.ico', 'Getting jph.ico from /foo/')\n",
|
1673 | 1668 | "test_r(cli, '/models/alexnet', 'alexnet')\n",
|
1674 | 1669 | "test_r(cli, '/files/foo', 'foo.txt')\n",
|
|
1873 | 1868 | {
|
1874 | 1869 | "data": {
|
1875 | 1870 | "text/plain": [
|
1876 |
| - "'Cookie was set at time 05:03:33.001178'" |
| 1871 | + "'Cookie was set at time 10:20:36.329470'" |
1877 | 1872 | ]
|
1878 | 1873 | },
|
1879 | 1874 | "execution_count": null,
|
|
1914 | 1909 | "name": "stdout",
|
1915 | 1910 | "output_type": "stream",
|
1916 | 1911 | "text": [
|
1917 |
| - "Set to 2024-08-14 05:03:33.052684\n" |
| 1912 | + "Set to 2024-08-15 10:20:36.410886\n" |
1918 | 1913 | ]
|
1919 | 1914 | },
|
1920 | 1915 | {
|
1921 | 1916 | "data": {
|
1922 | 1917 | "text/plain": [
|
1923 |
| - "'Session time: 2024-08-14 05:03:33.052684'" |
| 1918 | + "'Session time: 2024-08-15 10:20:36.410886'" |
1924 | 1919 | ]
|
1925 | 1920 | },
|
1926 | 1921 | "execution_count": null,
|
|
1948 | 1943 | "\n",
|
1949 | 1944 | "<!-- do not remove -->\n",
|
1950 | 1945 | "\n",
|
1951 |
| - "\n", |
1952 |
| - "## 0.3.4\n", |
| 1946 | + "## 0.3.7\n", |
1953 | 1947 | "\n",
|
1954 | 1948 | "### New Features\n",
|
1955 | 1949 | "\n",
|
1956 |
| - "- Experime\n" |
| 1950 | + "- Add `relo\n" |
1957 | 1951 | ]
|
1958 | 1952 | }
|
1959 | 1953 | ],
|
|
0 commit comments