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

Re: Using Dash

Posted: Mon 04 Nov 04 2019 12:23 pm
by Daniel Wee
The points of concern are:-

/etc/apache2/sites-available/000-default.conf
- add Listen 8054 (or whichever port you will be using)

/etc/apache2/sites-available/app.conf (whatever your app happens to be)
- <VirtualHost: *:8054> (or whichever port you will be using)

/etc/apache2/sites-available/default-ssl.conf
- ProxyPass "/virtualdirectory/" "http://realurl:8054/" (where real url can be 127.0.0.1 or wherever the app is being served from)
- ProxyPassReverse "/virtualdirectory/" "http://realurl:8054/"
- repeat this for the 443 segment below

check that /var/www/html/wsgi/app.wsgi is owned by www-data:www-data
- from appscript import server as application (here appscript is the actual python script - could be mapbox.py or similar)

sudo a2ensite app.conf (to enable the site)
sudo systemctl reload apache2

Re: Using Dash

Posted: Mon 04 Nov 04 2019 3:46 pm
by Daniel Wee
Places where the domain name clashes:-

/etc/apache2/sites-enabled/default-ssl.conf
- ServerName in the <VirtualHost *:80> section

/etc/apache2/sites-enabled/000-default.conf
- ServerName and ServerAlias in the <VirtualHost *:80> section