From ced0197019050893b9bef77c21e0d99174abdc76 Mon Sep 17 00:00:00 2001 From: Daniel Roy Greenfeld Date: Fri, 27 Dec 2024 08:43:54 -0500 Subject: [PATCH] Add pdf extension to static routes --- fasthtml/core.py | 2 +- nbs/api/00_core.ipynb | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/fasthtml/core.py b/fasthtml/core.py index e85da41c..e41d69e1 100644 --- a/fasthtml/core.py +++ b/fasthtml/core.py @@ -734,7 +734,7 @@ def reg_re_param(m, s): # %% ../nbs/api/00_core.ipynb # Starlette doesn't have the '?', so it chomps the whole remaining URL reg_re_param("path", ".*?") -reg_re_param("static", "ico|gif|jpg|jpeg|webm|css|js|woff|png|svg|mp4|webp|ttf|otf|eot|woff2|txt|html|map") +reg_re_param("static", "ico|gif|jpg|jpeg|webm|css|js|woff|png|svg|mp4|webp|ttf|otf|eot|woff2|txt|html|map|pdf") @patch def static_route_exts(self:FastHTML, prefix='/', static_path='.', exts='static'): diff --git a/nbs/api/00_core.ipynb b/nbs/api/00_core.ipynb index 5ac3a78d..e13056e7 100644 --- a/nbs/api/00_core.ipynb +++ b/nbs/api/00_core.ipynb @@ -131,7 +131,7 @@ { "data": { "text/plain": [ - "datetime.datetime(2024, 12, 20, 14, 0)" + "datetime.datetime(2024, 12, 27, 14, 0)" ] }, "execution_count": null, @@ -1230,7 +1230,7 @@ { "data": { "text/plain": [ - "'af1b5dfe-6a32-4348-b1de-692f979f20fb'" + "'a2597a39-e99d-4460-90b9-2ca21e87bc8f'" ] }, "execution_count": null, @@ -2478,13 +2478,13 @@ "name": "stdout", "output_type": "stream", "text": [ - "Set to 2024-12-20 19:21:33.748637\n" + "Set to 2024-12-27 08:45:58.732664\n" ] }, { "data": { "text/plain": [ - "'Session time: 2024-12-20 19:21:33.748637'" + "'Session time: 2024-12-27 08:45:58.732664'" ] }, "execution_count": null, @@ -3005,7 +3005,7 @@ { "data": { "text/plain": [ - "'Cookie was set at time 19:21:34.644743'" + "'Cookie was set at time 08:45:58.893906'" ] }, "execution_count": null, @@ -3048,7 +3048,7 @@ "#| export\n", "# Starlette doesn't have the '?', so it chomps the whole remaining URL\n", "reg_re_param(\"path\", \".*?\")\n", - "reg_re_param(\"static\", \"ico|gif|jpg|jpeg|webm|css|js|woff|png|svg|mp4|webp|ttf|otf|eot|woff2|txt|html|map\")\n", + "reg_re_param(\"static\", \"ico|gif|jpg|jpeg|webm|css|js|woff|png|svg|mp4|webp|ttf|otf|eot|woff2|txt|html|map|pdf\")\n", "\n", "@patch\n", "def static_route_exts(self:FastHTML, prefix='/', static_path='.', exts='static'):\n", @@ -3064,7 +3064,7 @@ "metadata": {}, "outputs": [], "source": [ - "reg_re_param(\"imgext\", \"ico|gif|jpg|jpeg|webm\")\n", + "reg_re_param(\"imgext\", \"ico|gif|jpg|jpeg|webm|pdf\")\n", "\n", "@rt(r'/static/{path:path}{fn}.{ext:imgext}')\n", "def get(fn:str, path:str, ext:str): return f\"Getting {fn}.{ext} from /{path}\"\n",