Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pdf extension to static routes #616

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading