Black Lives Matter. Please consider donating to Black Girls Code today.

URL Not Found - Multi-Page Dash App

This is my first time deploying a python developed app. Tried to run the multi page app in wsgi but its giving the error

My question now is when running the dash app in flask, what do I need to write at the top. Do i have to put a url at the top. of the app. I had written the following

from flask import Flask
app = dash.Dash(__name__, server=server)

but it kept on returning the same error of not displaying. What could be the possible error given that we deployed a hello script and it worked

This was based on reading, Dash on Multi-Page Site, @app.route? (Flask to Dash) and . Not that I got it all right but reset it a couple of times and tried over and over. Was using apache.

This is more of a deployment/hosting question regarding hosting Flask apps than a Dash specific one (all Dash apps use Flask). It really depends on how you’re serving the WSGI app. You mentioned that you’re using Apache, is this using mod_wsgi?

However you’re serving it, it’s unlikely you’ll be entering a .py extension into the URL. Unless you explicitly need to host multiple Dash apps alongside each other, you don’t need to use the DispatcherMiddleware from that post.

A simple way to get a Dash app deployed using the Gunicorn WSGI server assuming you have an file with a Dash instance in an ‘app’ variable:

$ pip install gunicorn
$ gunicorn --reload --bind '' app:app.server

Your app will then be available from http://HOSTNAME:5000

Hi Dash

While lauching gunicorn like this makes the app accessible from port 5000, how do I make sure that any other app is accessible via the default browser port (port 80) without invoking gunicorn manually as above.

Thank you

If you want make your Dash app publicly available on port 80, you probably want to use an HTTP proxy server to proxy incoming request to Gunicorn. The Gunicorn docs recommend nginx:

If you’re running it on a server that’s always on, then you only need to start gunicorn once. You could also create a service of some kind that runs your gunicorn script at startup if needed. You should be able to find lots of guides to achieving these things online, as this is now a general question about hosting a Flask app with gunicorn and not Dash specific.

1 Like