🚀 Gen 5 of the leading AI app deployment platform launches October 6. Click for the livestream.

Deploy Dash on apache server [solved!]

@gerrit - I just ran your example:

# -*- coding: utf-8 -*-
import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.graph_objs as go
import csv
from datetime import datetime as dt

app = dash.Dash(__name__)
app.config.update({
    #'url_base_pathname': '/showtemperature1/',
    # as the proxy server will remove the prefix
    'routes_pathname_prefix': '/showtemperature2/',

    # the front-end will prefix this string to the requests
    # that are made to the proxy server
    'requests_pathname_prefix': '/pompidom3/'
})
server = app.server

app.layout = html.Div([])

if __name__ == '__main__':
    app.run_server(debug=True)

Visiting http://localhost:8050 results in:

(vv) ~/Repos/dash-stuff/dash-sandbox (master)
♡♡ python dash-routes-config.py
 * Running on http://127.0.0.1:8050/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 150-080-314
127.0.0.1 - - [12/Sep/2017 17:06:40] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [12/Sep/2017 17:06:41] "GET /pompidom3/_dash-layout HTTP/1.1" 200 -
127.0.0.1 - - [12/Sep/2017 17:06:41] "GET /pompidom3/_dash-dependencies HTTP/1.1" 200 -

With:

$ pip freeze | grep dash
dash==0.18.3
dash-core-components==0.12.5
dash-html-components==0.7.0
dash-renderer==0.9.0
dash-table-experiments==0.5.0

I copied your code, I had to make one adjustment, as I run dash on a raspberry pi without windowing system I had to put in host=‘0.0.0.0’:

if __name__ == '__main__':
    app.run_server(debug=True, host='0.0.0.0') 

resulting in:

pi@rpizolder ~/bin $ python testdash.py 
 * Running on http://0.0.0.0:8050/
 * Restarting with reloader
192.168.2.57 - - [13/Sep/2017 20:59:45] "GET / HTTP/1.1" 200 -
192.168.2.57 - - [13/Sep/2017 20:59:45] "GET /_dash-layout HTTP/1.1" 200 -
192.168.2.57 - - [13/Sep/2017 20:59:45] "GET /_dash-dependencies HTTP/1.1" 200 -
192.168.2.57 - - [13/Sep/2017 20:59:45] "GET /_dash-routes HTTP/1.1" 200 -

and:

$ pip freeze | grep dash
dash==0.18.3
dash-renderer==0.9.0

What is the difference with or without setting ‘routes_pathname_prefix’ to ‘/showtemperature2/’ here in this example?

Problem found, python 2.7 and 3 were mixed up.
pip freeze was referring to python3 while I was using 2.7 for running the script.

sudo easy_install-2.7 -U pip

and upgrading the components using python 2.7, made my day.

Thanks chris for your effort.

2 Likes

Thought I’d update this thread since the solutions above didn’t work for me. I think the config system changed to be constructor based somewhere along the way. I’m on dash-0.40.0 now.

The below worked for me to host my dash app off a url-prefix.

In app.py:

app = dash.Dash(__name__, external_stylesheets=external_stylesheets, routes_pathname_prefix='/blarg/')

You saved my day!!! Thanks

Those workaround doesn’t work for dash=1.14.0. Could you provide solution for this version?

2 Likes