Skip to content

Commit

Permalink
Add pdf extension to static routes
Browse files Browse the repository at this point in the history
  • Loading branch information
pydanny committed Dec 27, 2024
1 parent 11dc14b commit ced0197
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion fasthtml/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'):
Expand Down
14 changes: 7 additions & 7 deletions nbs/api/00_core.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
{
"data": {
"text/plain": [
"datetime.datetime(2024, 12, 20, 14, 0)"
"datetime.datetime(2024, 12, 27, 14, 0)"
]
},
"execution_count": null,
Expand Down Expand Up @@ -1230,7 +1230,7 @@
{
"data": {
"text/plain": [
"'af1b5dfe-6a32-4348-b1de-692f979f20fb'"
"'a2597a39-e99d-4460-90b9-2ca21e87bc8f'"
]
},
"execution_count": null,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit ced0197

Please sign in to comment.