Using app.static twice reports a deprecation warning

I am serving 2 different static directories, when calling app.static a second time I get a warning:

DeprecationWarning: [DEPRECATION v23.3] Duplicate route names detected: __main__.static. In the future, Sanic will enforce uniqueness in route naming.
app = Sanic(__name__) 
app.static('/static', str(SCRIPT_DIR.joinpath('static_content').resolve())) 
app.static('/static_common', str(SCRIPT_DIR.joinpath('../common_content').resolve()))

I opened a ticket at https://github.com/sanic-org/sanic/issues/2674 and was told to ask in the forums about why this isn’t working.

I looked through the documentation and didn’t see a way to specify 2 different static locations so that a different method name is used. Can someone point me to the documentation or an example the specifies how to do this properly?

app.static API Docs

The problem is that by default app.stat() has a default parameter of name=“static”

app.static('/static', str(SCRIPT_DIR.joinpath('static_content').resolve()), name="static_default") 
app.static('/static_common', str(SCRIPT_DIR.joinpath('../common_content').resolve()), name="static_common")

should work

1 Like

Yep, that did it. Thank you!

We will have to come up with some way to create default names for static for this next release.