[solved] Dash on IIS 8 - TypeError: 'Dash' object is not callable

Trying to get Dash running on MS server using IIS (internet Information Services), only server my work allows me to use.
I’ve followed the tutorial on http://netdot.co/2015/03/09/flask-on-iis/ for creating a flask site and have an example flask site running.
Then copying the code over from the getting started guide and changing the app for deployment.

  Error occurred:
Traceback (most recent call last):
  File "C:\inetpub\wwwroot\dash\wfastcgi.py", line 736, in main
    result = handler(record.params, response.start)
TypeError: 'Dash' object is not callable

Code used below and this has been checked that it works locally.

import flask
import dash
import dash_core_components as dcc
import dash_html_components as html

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

app.layout = html.Div(children=[
    html.H1(children='Hello Dash'),

    html.Div(children='''
        Dash: A web application framework for Python.
    '''),

    dcc.Graph(
        id='example-graph',
        figure={
            'data': [
                {'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name': 'SF'},
                {'x': [1, 2, 3], 'y': [2, 4, 5], 'type': 'bar', 'name': 'Montreal'},
            ],
            'layout': {
                'title': 'Dash Data Visualization'
            }
        }
    )
])

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

Any help much appreciated.

From that tutorial:

http://netdot.co/images/wsgi_handler.png

The first app corresponds to app.py. The second app corresponds to the variable app instead the file app.py. In that example, the app variable was corresponding to the flask instance. In your example, app is the Dash app and server is the flask instance.

So, I believe that you need to change this WSGI_HANDLER to be app.server instead of app.app

3 Likes

Thanks for the quick reply chriddyp. Worked perfectly and I learnt something from 2 days of struggle.

I hope all your effort helps build a strong community here.

2 Likes

Thanks, the solution really helps a lot!

1 Like

I am getting the same error on elastic beanstalk.
Can you pleas help me out ?
Attaching the logs.

Did you see @chriddyp’s response above? It looks like the same problem. Your WSGI callable needs to point to the server attribute of your Dash instance, rather than the Dash instance itself.

And how can I do that on AWS Elastic Beanstalk ?

Looking at the AWS docs, it looks like you need to provide a path to a python file rather than allowing you to specificy an attribute within a module, so I think you want to set the WSGIPATH variable to the path of a file wsgi.py and in that file needs to be a variable application, which contains the Flask instance. So you could simple put in that file:

from app import app
application = app.server

Assuming you have a file app.py which contains a Dash instance app

AWS Docs are here: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-container.html

1 Like

Thanks a lot, it worked.

1 Like