From 938d2b59231a06e4bc59b55ae58da3d1549631bc Mon Sep 17 00:00:00 2001 From: Adam Hopkins Date: Sun, 21 Mar 2021 15:03:54 +0200 Subject: [PATCH] Static dir 2075 (#2076) * Add support for nested static directories * Add support for nested static directories * Bump version 21.3.1 --- examples/static/favicon.ico | Bin 0 -> 15086 bytes examples/static/images/logo.png | Bin 0 -> 13600 bytes examples/static/robots.txt | 2 ++ examples/static_assets.py | 6 ++++++ sanic/__version__.py | 2 +- sanic/mixins/routes.py | 2 +- tests/static/nested/dir/foo.txt | 1 + tests/test_static.py | 9 +++++++++ 8 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 examples/static/favicon.ico create mode 100644 examples/static/images/logo.png create mode 100644 examples/static/robots.txt create mode 100644 examples/static_assets.py create mode 100644 tests/static/nested/dir/foo.txt diff --git a/examples/static/favicon.ico b/examples/static/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..3b39e5d7f68d70bca8d607aeee0496df4b17cb5b GIT binary patch literal 15086 zcmeI336NIB5yu}zN~1<4F+s7yvWiBNXkv~sAt^CI6LY63l@LiHC`7>v6b}#&4vBcg zt5m#E@WL3>C|YVnSMk6j-uJPr_lbfEESfi+|L@J4@0~uv@lB;BJ^3){SeQ-!Z_g(VTBOnb;=`SEl?-ar|qKxwEA{+Kg44L zVJ`um$cP-ZWNqYKpaD&2Z_pL}5Zx^W#(cRDcs3$mqjjJOZFp?CI{P4c1BCkocr;=o zjmlhFFW45m2CR-gh|VD4S)nU*UMhchh8H{stx6x%9=)$=*-QJ-sd13p{e@sNf##Y{ z83$zOzcS;X`uG{<(VDcGYPvxNWLdw_KB(?+0bkISbG4ehrRB(gEPFK~zv?v!_~LTi zf6mf<*0*%z2J-pJt4@aOS^1H9*?zq&1^aGXth4V%{+X1vw1F0gX$6`kDY76_Q@uW@ z&Um3*@8UVSx1}>jnY-n5bMvN~YdPOz*8b-9|AM7QY-{Pwr<%KOw#U7fnY(j_xjQZ} zH~%7Y_grG`u9?2=O(&b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|d-l h|2AHJIlKoo*J?EQvi?_%{WlY!t*#HRQ?-ly{{RnIX!`&F literal 0 HcmV?d00001 diff --git a/examples/static/robots.txt b/examples/static/robots.txt new file mode 100644 index 00000000..1f53798b --- /dev/null +++ b/examples/static/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: / diff --git a/examples/static_assets.py b/examples/static_assets.py new file mode 100644 index 00000000..23f324ef --- /dev/null +++ b/examples/static_assets.py @@ -0,0 +1,6 @@ +from sanic import Sanic + + +app = Sanic(__name__) + +app.static("/", "./static") diff --git a/sanic/__version__.py b/sanic/__version__.py index 7cd09f62..66db1623 100644 --- a/sanic/__version__.py +++ b/sanic/__version__.py @@ -1 +1 @@ -__version__ = "21.3.0" +__version__ = "21.3.1" diff --git a/sanic/mixins/routes.py b/sanic/mixins/routes.py index f181e83b..f57bf230 100644 --- a/sanic/mixins/routes.py +++ b/sanic/mixins/routes.py @@ -776,7 +776,7 @@ class RouteMixin: # If we're not trying to match a file directly, # serve from the folder if not path.isfile(file_or_directory): - uri += "/<__file_uri__>" + uri += "/<__file_uri__:path>" # special prefix for static files # if not static.name.startswith("_static_"): diff --git a/tests/static/nested/dir/foo.txt b/tests/static/nested/dir/foo.txt new file mode 100644 index 00000000..257cc564 --- /dev/null +++ b/tests/static/nested/dir/foo.txt @@ -0,0 +1 @@ +foo diff --git a/tests/test_static.py b/tests/test_static.py index 24b5c568..532adb80 100644 --- a/tests/test_static.py +++ b/tests/test_static.py @@ -445,3 +445,12 @@ def test_static_name(app, static_file_directory, static_name, file_name): request, response = app.test_client.get(f"/static/{file_name}") assert response.status == 200 + + +def test_nested_dir(app, static_file_directory): + app.static("/static", static_file_directory) + + request, response = app.test_client.get("/static/nested/dir/foo.txt") + + assert response.status == 200 + assert response.text == "foo\n"