Skip to content

Commit ced0197

Browse files
committed
Add pdf extension to static routes
1 parent 11dc14b commit ced0197

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

fasthtml/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ def reg_re_param(m, s):
734734
# %% ../nbs/api/00_core.ipynb
735735
# Starlette doesn't have the '?', so it chomps the whole remaining URL
736736
reg_re_param("path", ".*?")
737-
reg_re_param("static", "ico|gif|jpg|jpeg|webm|css|js|woff|png|svg|mp4|webp|ttf|otf|eot|woff2|txt|html|map")
737+
reg_re_param("static", "ico|gif|jpg|jpeg|webm|css|js|woff|png|svg|mp4|webp|ttf|otf|eot|woff2|txt|html|map|pdf")
738738

739739
@patch
740740
def static_route_exts(self:FastHTML, prefix='/', static_path='.', exts='static'):

nbs/api/00_core.ipynb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
{
132132
"data": {
133133
"text/plain": [
134-
"datetime.datetime(2024, 12, 20, 14, 0)"
134+
"datetime.datetime(2024, 12, 27, 14, 0)"
135135
]
136136
},
137137
"execution_count": null,
@@ -1230,7 +1230,7 @@
12301230
{
12311231
"data": {
12321232
"text/plain": [
1233-
"'af1b5dfe-6a32-4348-b1de-692f979f20fb'"
1233+
"'a2597a39-e99d-4460-90b9-2ca21e87bc8f'"
12341234
]
12351235
},
12361236
"execution_count": null,
@@ -2478,13 +2478,13 @@
24782478
"name": "stdout",
24792479
"output_type": "stream",
24802480
"text": [
2481-
"Set to 2024-12-20 19:21:33.748637\n"
2481+
"Set to 2024-12-27 08:45:58.732664\n"
24822482
]
24832483
},
24842484
{
24852485
"data": {
24862486
"text/plain": [
2487-
"'Session time: 2024-12-20 19:21:33.748637'"
2487+
"'Session time: 2024-12-27 08:45:58.732664'"
24882488
]
24892489
},
24902490
"execution_count": null,
@@ -3005,7 +3005,7 @@
30053005
{
30063006
"data": {
30073007
"text/plain": [
3008-
"'Cookie was set at time 19:21:34.644743'"
3008+
"'Cookie was set at time 08:45:58.893906'"
30093009
]
30103010
},
30113011
"execution_count": null,
@@ -3048,7 +3048,7 @@
30483048
"#| export\n",
30493049
"# Starlette doesn't have the '?', so it chomps the whole remaining URL\n",
30503050
"reg_re_param(\"path\", \".*?\")\n",
3051-
"reg_re_param(\"static\", \"ico|gif|jpg|jpeg|webm|css|js|woff|png|svg|mp4|webp|ttf|otf|eot|woff2|txt|html|map\")\n",
3051+
"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",
30523052
"\n",
30533053
"@patch\n",
30543054
"def static_route_exts(self:FastHTML, prefix='/', static_path='.', exts='static'):\n",
@@ -3064,7 +3064,7 @@
30643064
"metadata": {},
30653065
"outputs": [],
30663066
"source": [
3067-
"reg_re_param(\"imgext\", \"ico|gif|jpg|jpeg|webm\")\n",
3067+
"reg_re_param(\"imgext\", \"ico|gif|jpg|jpeg|webm|pdf\")\n",
30683068
"\n",
30693069
"@rt(r'/static/{path:path}{fn}.{ext:imgext}')\n",
30703070
"def get(fn:str, path:str, ext:str): return f\"Getting {fn}.{ext} from /{path}\"\n",

0 commit comments

Comments
 (0)