Page 1 of 1

Using Dash

Posted: Thu 12 Apr 12 2018 1:17 pm
by Daniel Wee

Code: Select all

import dash
from dash.dependencies import Input, Output
import dash_core_components as dcc
import dash_html_components as html


app = dash.Dash()

# define the layout of the page
app.layout = html.Div([
	dcc.Input(id='input', value='Enter something here!', type='text'),
	html.Div(id='output')
])

# define the callback function
# this decorator function replaces some called function and performs the actual value update
# the function to update the value must immediately follow this decorator
@app.callback(
	# change element marked 'output' whenever element 'input' changes its 'value'
	Output(component_id='output', component_property='children'),
	[Input(component_id='input', component_property='value')]
)
def update_value(input_data):
	return 'Input: "{}"'.format(input_data)

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

Re: Using Dash

Posted: Sun 06 May 06 2018 12:58 am
by Daniel Wee
To configure apache2 to redirect an alias to a different port, use proxy functions:-

https://stackoverflow.com/questions/345 ... internally
https://www.digitalocean.com/community/ ... untu-16-04

This somewhat works but seems to fail in loading the layout. May need more work on the code.

Trying to resolve "Layout not loading issue"

Posted: Sun 06 May 06 2018 1:25 am
by Daniel Wee

Re: Using Dash

Posted: Sun 06 May 06 2018 1:35 am
by Daniel Wee
Resolution involved:-

Setting up mod_wsgi to work:-

see files:-

See Proxy lines for port 80 and 443 (SSL)
/etc/apache2/sites-enabled/default-ssl.conf

See how to get apache2 to serve up dash on given port 8050
/etc/apache2/sites-enabled/attendance.conf

You'll need to enable this with:-

Code: Select all

sudo a2ensite attendance
sudo service apache2 reload
Also need to make sure apache2 is listening on the port. See:-
/etc/apache2/sites-enabled/000-default.conf

See intermediate launch file:-
/var/www/html/wsgi/attendance.wsgi
*note especially the hash bang line at the start

See dash python file:-
/home/daniel/python/attendance.py
* see line with app.config.requests_pathname_prefix = ""

https://community.plot.ly/t/dash-error- ... out/8139/5

Re: Using Dash

Posted: Mon 07 May 07 2018 1:02 am
by Daniel Wee