Skip to content

Commit

Permalink
Merge pull request #616 from AnswerDotAI/add-pdf-2-reg_re_param
Browse files Browse the repository at this point in the history
Add pdf extension to static routes
  • Loading branch information
jph00 authored Jan 6, 2025
2 parents 7b258d7 + a787fa3 commit 3a9797e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion fasthtml/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,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
4 changes: 2 additions & 2 deletions nbs/api/00_core.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3095,7 +3095,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 @@ -3111,7 +3111,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 3a9797e

Please sign in to comment.