✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🧬 Learn how to build RNA-Seq data apps with Python & Dash. Register for the May 20 Webinar!

Can't get assets/ folder to be served when using nginx

Hi all,

I assume I’m doing something wrong here.

I have an app with a CSS file in the assets/ folder, which I understand is automatically served. This works fine when I am running the app on localhost, but when I deploy it to a remote server, this CSS file does not appear to be loaded. I can see the app content, and callbacks are working, but there is no styling.

I’m deploying behind nginx and gunicorn if that makes any difference. I’m relatively new to this configuration, and I’m not sure exactly how Dash is “automatically” serving the assets in assets/, so perhaps I’m overlooking something obvious.

A quick googling suggests that this issue is sometimes due to not having __name__ in the dash.Dash() instantiation, but I do already have that.

Any help appreciated!


An update:

If I don’t use either nginx or gunicorn and run my app directly on port 80, the assets/ CSS loads.

If I use nginx but don’t use gunicorn, the CSS does not load.

So I assume what I am doing wrong is something to do with serving static assets behind nginx.

I’m actually planning to give a talk showing off my app and Dash itself on Wednesday, so any advice (including on workarounds) is welcome! @chriddyp help!?

Part of my difficulty is that the assets/ functionality seems pretty recent so most of the forum discussions of problems are centred around older methods for serving static content. Possibly what I’m experiencing is a bug, but I don’t know how to be sure.

Thanks for any help!!

@nedned has solved this one - it has nothing to do with Dash or even nginx; I had files under ~/.local that were screwing up library versions.

1 Like