Skip to content

Commit 3a9797e

Browse files
authored
Merge pull request #616 from AnswerDotAI/add-pdf-2-reg_re_param
Add pdf extension to static routes
2 parents 7b258d7 + a787fa3 commit 3a9797e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

fasthtml/core.py

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

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

nbs/api/00_core.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3095,7 +3095,7 @@
30953095
"#| export\n",
30963096
"# Starlette doesn't have the '?', so it chomps the whole remaining URL\n",
30973097
"reg_re_param(\"path\", \".*?\")\n",
3098-
"reg_re_param(\"static\", \"ico|gif|jpg|jpeg|webm|css|js|woff|png|svg|mp4|webp|ttf|otf|eot|woff2|txt|html|map\")\n",
3098+
"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",
30993099
"\n",
31003100
"@patch\n",
31013101
"def static_route_exts(self:FastHTML, prefix='/', static_path='.', exts='static'):\n",
@@ -3111,7 +3111,7 @@
31113111
"metadata": {},
31123112
"outputs": [],
31133113
"source": [
3114-
"reg_re_param(\"imgext\", \"ico|gif|jpg|jpeg|webm\")\n",
3114+
"reg_re_param(\"imgext\", \"ico|gif|jpg|jpeg|webm|pdf\")\n",
31153115
"\n",
31163116
"@rt(r'/static/{path:path}{fn}.{ext:imgext}')\n",
31173117
"def get(fn:str, path:str, ext:str): return f\"Getting {fn}.{ext} from /{path}\"\n",

0 commit comments

Comments
 (0)