pydoc
running mode 1
python -m pydoc math
running mode 2
python -m pydoc -b
start a documentation web server
dinsdag 15 oktober 2019
woensdag 9 oktober 2019
DASH: CHLOROMAPS
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 8 10:28:13 2019
@author: wagenerj
"""
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import geopandas as gpd
import pandas as pd
import matplotlib.pyplot as plt
import random
import mymod
import chart_studio.plotly as py
import plotly.graph_objs as go
counties = mymod.geefGebiedenGJSON()
df= mymod.geefGebiedenGDF()
app = dash.Dash(__name__)
#werkeend blok alles in 1 commando
# =============================================================================
# mygraph= dcc.Graph(
# figure = go.Figure(go.Choroplethmapbox(geojson=counties, locations=df.myindex, z=df.myval,
# colorscale="Viridis", zmin=0, zmax=12,
# marker_opacity=0.5, marker_line_width=0)
#
# ,layout=go.Layout(
# title='US Export of Plastic Scrap',
# showlegend=True,
# legend=go.layout.Legend(x=0, y=1.0),
# margin=go.layout.Margin(l=40, r=0, t=40, b=30)
# )
# ),style={'height': 300},id='my-graph')
#
# app.layout=html.Div(mygraph)
#
# =============================================================================
# =============================================================================
# myfigure=go.Figure(go.Choroplethmapbox(geojson=counties, locations=df.myindex, z=df.myval,
# colorscale="Viridis", zmin=0, zmax=6,
# marker_opacity=0.5, marker_line_width=0)
#
# ,layout=go.Layout(
# title='Gebieden Amsterdam values ',
# showlegend=True,
# legend=go.layout.Legend(x=0, y=1.0),
# margin=go.layout.Margin(l=40, r=0, t=40, b=30)
# ))
#
#
# myfigure.update_layout(mapbox_style="open-street-map", mapbox_zoom=3, mapbox_center = {"lat": 37.0902, "lon": -95.7129})
#
# mygraph= dcc.Graph(figure=myfigure,style={'height': 600},id='graf1')
#
# app.layout=html.Div([mygraph])
#
# =============================================================================
def makeChloromap() :
myChloromapbox =go.Choroplethmapbox(geojson=counties, locations=df.myindex, z=df.myval, hovertext="ok",
colorscale="Blues", zmin=0, zmax=6,
marker_opacity=1, marker_line_width=0)
myLayout=go.Layout(
title='Gebieden Amsterdam values ',
showlegend=True,
legend=go.layout.Legend(x=0, y=1.0),
margin=go.layout.Margin(l=40, r=0, t=40, b=30)
)
myfigure=go.Figure(myChloromapbox, myLayout)
myfigure.update_layout(mapbox_style="open-street-map", mapbox_zoom=10, mapbox_center = {"lat": 52.370216, "lon": 4.895168})
mygraph= dcc.Graph(figure=myfigure,style={'height': 600,'width':900},id='graf1')
return mygraph
def makeChloro():
myfigure = go.Figure(data=go.Choropleth(data=df,
locations=df['myindex'], # Spatial coordinates
z = df['myval'], # Data to be color-coded
locationmode = 'country names', # set of locations match entries in `locations`
colorscale = 'Reds',
colorbar_title = "Millions USD",
))
# myfigure.update_layout(mapbox_style="open-street-map", mapbox_zoom=10, mapbox_center = {"lat": 52.370216, "lon": 4.895168})
mygraph= dcc.Graph(figure=myfigure,style={'height': 600,'width':900},id='graf2')
return mygraph
app.layout=html.Div([makeChloro()])
if __name__ == '__main__':
app.run_server(debug=True)
"""
Created on Tue Oct 8 10:28:13 2019
@author: wagenerj
"""
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import geopandas as gpd
import pandas as pd
import matplotlib.pyplot as plt
import random
import mymod
import chart_studio.plotly as py
import plotly.graph_objs as go
counties = mymod.geefGebiedenGJSON()
df= mymod.geefGebiedenGDF()
app = dash.Dash(__name__)
#werkeend blok alles in 1 commando
# =============================================================================
# mygraph= dcc.Graph(
# figure = go.Figure(go.Choroplethmapbox(geojson=counties, locations=df.myindex, z=df.myval,
# colorscale="Viridis", zmin=0, zmax=12,
# marker_opacity=0.5, marker_line_width=0)
#
# ,layout=go.Layout(
# title='US Export of Plastic Scrap',
# showlegend=True,
# legend=go.layout.Legend(x=0, y=1.0),
# margin=go.layout.Margin(l=40, r=0, t=40, b=30)
# )
# ),style={'height': 300},id='my-graph')
#
# app.layout=html.Div(mygraph)
#
# =============================================================================
# =============================================================================
# myfigure=go.Figure(go.Choroplethmapbox(geojson=counties, locations=df.myindex, z=df.myval,
# colorscale="Viridis", zmin=0, zmax=6,
# marker_opacity=0.5, marker_line_width=0)
#
# ,layout=go.Layout(
# title='Gebieden Amsterdam values ',
# showlegend=True,
# legend=go.layout.Legend(x=0, y=1.0),
# margin=go.layout.Margin(l=40, r=0, t=40, b=30)
# ))
#
#
# myfigure.update_layout(mapbox_style="open-street-map", mapbox_zoom=3, mapbox_center = {"lat": 37.0902, "lon": -95.7129})
#
# mygraph= dcc.Graph(figure=myfigure,style={'height': 600},id='graf1')
#
# app.layout=html.Div([mygraph])
#
# =============================================================================
def makeChloromap() :
myChloromapbox =go.Choroplethmapbox(geojson=counties, locations=df.myindex, z=df.myval, hovertext="ok",
colorscale="Blues", zmin=0, zmax=6,
marker_opacity=1, marker_line_width=0)
myLayout=go.Layout(
title='Gebieden Amsterdam values ',
showlegend=True,
legend=go.layout.Legend(x=0, y=1.0),
margin=go.layout.Margin(l=40, r=0, t=40, b=30)
)
myfigure=go.Figure(myChloromapbox, myLayout)
myfigure.update_layout(mapbox_style="open-street-map", mapbox_zoom=10, mapbox_center = {"lat": 52.370216, "lon": 4.895168})
mygraph= dcc.Graph(figure=myfigure,style={'height': 600,'width':900},id='graf1')
return mygraph
def makeChloro():
myfigure = go.Figure(data=go.Choropleth(data=df,
locations=df['myindex'], # Spatial coordinates
z = df['myval'], # Data to be color-coded
locationmode = 'country names', # set of locations match entries in `locations`
colorscale = 'Reds',
colorbar_title = "Millions USD",
))
# myfigure.update_layout(mapbox_style="open-street-map", mapbox_zoom=10, mapbox_center = {"lat": 52.370216, "lon": 4.895168})
mygraph= dcc.Graph(figure=myfigure,style={'height': 600,'width':900},id='graf2')
return mygraph
app.layout=html.Div([makeChloro()])
if __name__ == '__main__':
app.run_server(debug=True)
vrijdag 4 oktober 2019
uWSGI Installation
Deployment of a Flask application for public access requires a real
webserver be installed in front of the application. That, in turn,
requires, a mechanism for linking the webserver to the Flask
application.
In this post, we'll install the uWSGI package and use it to link a rudimentary Flask application to an Nginx server. As part of the uWSGI installation, we'll set up a Python virtual environment to house both the Flask application and the uWSGI package.
In order to follow this post, you should have a recent version of Python and Nginx (see sidebar).
We used my Antsle to create a Ubuntu 16.04 installation (named "helium") where we have installed recent releases of Python and Nginx (see sidebar).
We're going to install uWSGI in a Python virtual environment, so first we set up a new virtual environment and activate it. NOTE: You can, of course, set up your virtual environment anywhere you have rights, but my common practice is to put them all in my home account under a single "venvs" directory.
Both Flask and uWSGI are installed in the virtual environment. Check the versions.
Now everything we need is installed: Python, Nginx, Flask and uWSGI. This is what we are going to do:
File: __init__.py (shown below)
File: routes.py (shown below)
File: run_me.py (shown below)
File: config.py (shown below)
To run the Flask application, set up in the .../alex directory:
The module parameter identifies the Python file to run (run_me.py) and the Flask application object (ned).
The master parameter is a standard setting for production environments.
The processes parameter is commonly set to 5 as a default. To get an optimal setting requires experimentation with the application under load.
The socket parameter provides the name of the socket connection between uWSGI and Nginx. Note that the socket value is also identified in the Nginx configuration file. These have to match in order for uWSGI to link correctly with Nginx - a common mechanism for coordinating application elements.
The chmod-socket parameter is supposed to provide the "uWSGI user" access to the socket. The value 664 is specified in the documentation, but it did not work for us, so we show it here as 666, which did work for us.
The vacuum parameter directs uWSGI to delete the Unix socket when the uWSGI server terminates.
The uid and gid parameters identify the user and group running the uWSGI server.
The die-on-term parameter directs uWSGI to "brutally reload all the workers and the master process" when the application exits.
The uwsgi.ini parameter file is shown below:
/etc/nginx/conf.d/helium.conf
The --ini uwsgi.ini parameter directs uWSGI to our .ini file.
The --daemonize uwsgi.log parameter runs this instance of the uWSGI server as a daemon process and directs the server to write its log output to uwsgi.log.
The --safe-pidfile /tmp/alex.pid parameter saves the pid for this uWSGI server process to the file "/tmp/alex.pid". That pid number is referenced to "gracefully" reload the uWSGI server or to stop it. (See this.)
One immediate implication of installing uWSGI into a Python virtual environment is that we should be able to run multiple Flask applications from separate virtual environments - each through its own uWSGI connection to Nginx. And it turns out that we can.
We're just going to sketch this implementation because it is so straightforward. We created a second virtual environment named "western" and installed both Flask and uWSGI as before. We made a project directory named "scifi" and a "noir" directory for the Flask application. The listings below show the substitutions in the western/scifi/noir setup. Compare to the sam/alex/paa setup above.
scifi/noir/init.py
In this post, we'll install the uWSGI package and use it to link a rudimentary Flask application to an Nginx server. As part of the uWSGI installation, we'll set up a Python virtual environment to house both the Flask application and the uWSGI package.
In order to follow this post, you should have a recent version of Python and Nginx (see sidebar).
uWSGI Installation
NOTE: As of January 28, 2019, these same instructions work for installing uWSGI version 2.0.17.1.We used my Antsle to create a Ubuntu 16.04 installation (named "helium") where we have installed recent releases of Python and Nginx (see sidebar).
We're going to install uWSGI in a Python virtual environment, so first we set up a new virtual environment and activate it. NOTE: You can, of course, set up your virtual environment anywhere you have rights, but my common practice is to put them all in my home account under a single "venvs" directory.
$ cd # /home/joe is the working directory
$ mkdir venvs # directory for virtual environments
$ cd venvs #
$ python3 -m venv sam # make sam virtual environment
$ source sam/bin/activate # activate the virtual environment
Once the virtual environment is activated, the system prompt is
prefixed with the name of the virtual environment - (sam). Check the
Python version. Next we use which -a to check for the multiple python3
installations: Ubuntu distro, our Python 3.7.0 installation, and the
python3 in the (sam) virtual environment. (sam) joe@helium:~/venvs$ python --version
Python 3.7.0
(sam) joe@helium:~/venvs$ which -a python3
/home/joe/venvs/sam/bin/python3
/usr/local/bin/python3
/usr/bin/python3
With the virtual environment in place, we can install Flask and
uWSGI. NOTE: The uWSGI install will fail unless you have a complete
Python installation. In particular, you need to have the python3-dev
package and the libssl-dev package installed. (See this post.) Both Flask and uWSGI are installed in the virtual environment. Check the versions.
(sam) joe@helium:~/alex$ pip install flask
(sam) joe@helium:~/alex$ pip install uwsgi
(sam) joe@helium:~/venvs$ which flask
/home/joe/venvs/sam/bin/flask
(sam) joe@helium:~/venvs$ flask --version
Flask 1.0.2
Python 3.7.0 (default, Oct 19 2018, 14:09:51)
[GCC 5.4.0 20160609]
(sam) joe@helium:~/venvs$ which uwsgi
/home/joe/venvs/sam/bin/uwsgi
(sam) joe@helium:~/venvs$ uwsgi --version
2.0.17.1
Installations Complete: Here's the PlanNow everything we need is installed: Python, Nginx, Flask and uWSGI. This is what we are going to do:
- We set up and run a simple Flask application without using either Nginx or uWSGI. Test the application using curl.
- We hook up our rudimentary Flask application to the Nginx server by using a uWSGI configuration file.
- As a bonus, we set up a second virtual environment ("western") with all the trimmings - uWSGI, Flask application, Nginx service, etc. - and run both applications at the same time.
Rudimentary Flask Application
There are many different ways to structure a Flask application. We'll use the following directory structure./home/joe
|
|-- /alex (project directory)
|
| -- /paa (application directory)
. |
. | -- /static (css, js, etc.)
. | -- /templates (html files)
. |
. | -- __init__.py
. | -- routes.py
. | :
. | :
|
| -- config.py
| -- run_me.py
| :
| :
This structure is a little overblown for the rudimentary Flask
application we are going to build, but it is illustrative of the setup
for a simple application (meaning no Blueprints). Also, we have made a
few files and directories with artificially distinct names so that
dependencies are a little clearer than in most tutorials.File: __init__.py (shown below)
from flask import Flask
ned = Flask(__name__)
ned.config.from_object('config')
NOTE: Only the root name of the config.py file (shown below) is used in the ned.config.from_object() call.File: routes.py (shown below)
from paa import ned
@ned.route('/')
def slash():
title = "<title>Ned's Greeting</title>"
greeting = '<span style="color: blue"><b>Howdy Doodly, Neighbor!'
return f'{title}\n{greeting}\n'
NOTE: Our default practice is to use single quotes for strings, but
the apostrophe in "Ned's Greeting" necessitates double quotes for the
title value.File: run_me.py (shown below)
from paa import ned
from paa import routes
if __name__ == '__main__':
ned.run()
NOTE: Flask defaults to serving the application at address
localhost:5000 unless some other host and port are specified in the
"ned.run()" statement. As you'll see later, there is no need for those
parameters when using uWSGI and Nginx in this example.File: config.py (shown below)
SECRET_KEY = 'ivegotasecret'
We've included a Flask SECRET_KEY configuration value here for the
sake of completeness. It is not necessary in the example shown above. In
any real Flask application (using Nginx and uWSGI), though, you're
going to use the "session" object at some point, and you cannot do that
unless you have set the SECRET_KEY configuration value. See this
StackOverflow question/answer for a full description of the Flask
"session" object. Test Flask App in Flask Development Environment
In order to test the Flask application using the curl command, we need to have two terminal sessions - one to execute the Flask app and one to execute the curl command.To run the Flask application, set up in the .../alex directory:
(sam) joe@helium:~/alex$ export FLASK_APP=run_me.py
(sam) joe@helium:~/alex$ flask run
* Serving Flask app "run_me.py"
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
.
.
.
[ctl-C to end the application after the curl test]
In another terminal window, enter the curl command:joe@helium:~$ curl localhost:5000
<title>Ned's Greeting</title>
<span style="color: blue"><b>Howdy Doodly, Neighbor!
Now we leave this minimally operational Flask application on the shelf while we put Nginx and uWSGI together.Set uWSGI Parameters to Work with Flask Application
The uwsgi.ini file sets values for all of the parameters required to link a Python-Flask application to the Nginx server.The module parameter identifies the Python file to run (run_me.py) and the Flask application object (ned).
The master parameter is a standard setting for production environments.
The processes parameter is commonly set to 5 as a default. To get an optimal setting requires experimentation with the application under load.
The socket parameter provides the name of the socket connection between uWSGI and Nginx. Note that the socket value is also identified in the Nginx configuration file. These have to match in order for uWSGI to link correctly with Nginx - a common mechanism for coordinating application elements.
The chmod-socket parameter is supposed to provide the "uWSGI user" access to the socket. The value 664 is specified in the documentation, but it did not work for us, so we show it here as 666, which did work for us.
The vacuum parameter directs uWSGI to delete the Unix socket when the uWSGI server terminates.
The uid and gid parameters identify the user and group running the uWSGI server.
The die-on-term parameter directs uWSGI to "brutally reload all the workers and the master process" when the application exits.
The uwsgi.ini parameter file is shown below:
[uwsgi]
module=run_me:ned
master = true
processes = 5
socket = baker.sock
chmod-socket = 666
vacuum = true
uid = joe
gid = www-data
die-on-term = true
Setup Nginx to Work With uWSGI Parameters
The Nginx configuration file shown below links up with the uWSGI server via the include and uwsgi_pass parameters./etc/nginx/conf.d/helium.conf
server {
listen 8181;
server_name localhost;
location / {
include uwsgi_params;
uwsgi_pass unix:/home/joe/alex/baker.sock;
}
}
The /etc/nginx/conf.d/helium.conf file is included in the last line
of the standard "starter" configuration file that comes with
installation of the Nginx server from the Nginx.org site. user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/helium.conf;
}
Run Nginx and uWSGI Servers
To restart the Nginx server:$ sudo service nginx restart
In order to start uWSGI properly for the .../alex/paa application,
you have to activate the sam virtual environment, then run the uWSGI
server.The --ini uwsgi.ini parameter directs uWSGI to our .ini file.
The --daemonize uwsgi.log parameter runs this instance of the uWSGI server as a daemon process and directs the server to write its log output to uwsgi.log.
The --safe-pidfile /tmp/alex.pid parameter saves the pid for this uWSGI server process to the file "/tmp/alex.pid". That pid number is referenced to "gracefully" reload the uWSGI server or to stop it. (See this.)
(sam) joe@helium:~/alex$ uwsgi --ini uwsgi.ini --daemonize uwsgi.log --safe-pidfile /tmp/alex.pid
And here's the greeting displayed from the command line with "curl localhost:8181": (sam) joe@helium:~$ curl localhost:8181
<title>Ned's Greeting</title>
<span style="color: blue"><b>Howdy Doodly, Neighbor!</b></span>
There we have it: the Flask application is joined to Nginx via uWSGI. Twice the Fun
But we could not resist checking this out.One immediate implication of installing uWSGI into a Python virtual environment is that we should be able to run multiple Flask applications from separate virtual environments - each through its own uWSGI connection to Nginx. And it turns out that we can.
We're just going to sketch this implementation because it is so straightforward. We created a second virtual environment named "western" and installed both Flask and uWSGI as before. We made a project directory named "scifi" and a "noir" directory for the Flask application. The listings below show the substitutions in the western/scifi/noir setup. Compare to the sam/alex/paa setup above.
scifi/noir/init.py
from flask import Flask
hitchcock = Flask(__name__)
hitchcock.config.from_object('config')
scifi/noir/views.py from noir import hitchcock
@hitchcock.route('/')
def slash():
title = f"<title>Confusion Cinema</title>"
greeting = f'<span style="color: blue"><b>Some like hot, psycho birds!</b></span>\n'
return f'{title}\n{greeting}\n'
scifi/run_fi.py from noir import hitchcock
from noir import views
if __name__ == '__main__':
hitchcock.run()
scifi/config.py SECRET_KEY = 'ivegotasecret'
scifi/uwsgi.ini [uwsgi]
module=run_fi:hitchcock
master = true
processes = 5
socket = marilyn.sock
chmod-socket = 666
vacuum = true
uid = joe
gid = www-data
die-on-term = true
We distinguish the two separate Flask applications by serving them
via separate ports. The uWSGI servers takes care of linking the Flask
applications to the correct ports for the Nginx server. server {
listen 8181;
server_name localhost;
location / {
include uwsgi_params;
uwsgi_pass unix:/home/joe/alex/baker.sock;
}
}
server {
listen 8080;
server_name localhost;
location / {
include uwsgi_params;
uwsgi_pass unix:/home/joe/scifi/marilyn.sock;
}
}
woensdag 2 oktober 2019
Integrate dash in flask Applicatie
maak virtuele omgeving
cd dashappspython -m venv venv_dash
source venv_dash/bin/activate
installeer flask en dash in virtuele omgeving
pip install flaskpip install dash
pip install dash-daq
uit virtuele omgeving
deactivateIntegreer Dash in Flask
(https://hackersandslackers.com/gaining-full-control-over-plotly-dash/)directorystructuur simpel
dashapps(dir)
-- mydashapp(dir)
-- __init__.py
-- routes.py
-- dash_application (dir)
--exampledash.py
-- wsgi.py
wsgi.py
from mydashapp import create_appapp = create_app()
if __name__ == "__main__":
app.run(host='0.0.0.0', debug=True)
__init__.py
"""Initialize app."""from flask import Flask
def create_app():
"""Construct the core application."""
app = Flask(__name__, instance_relative_config=False)
#app.config.from_object('config.Config')
with app.app_context():
# Import main Blueprint
#from . import routes
from mydashapp import routes
# Import Dash application
from .dash_application import exampledash
app = exampledash.Add_Dash(app)
return app
Uitleg:
het gaat hier om de volgende 2 regels
# Import Dash application
from .dash_application import dash_example
app = dash_example.Add_Dash(app)
dash_example
is actually a Python file ( ./dash_application/dash_example.py
) which contains our Dash app! Dash typically likes to have a single .py file per view, which turns out to work great for us. Let's look at why this works by checking dash_example.py
:routes.py
import osfrom flask import Blueprint, render_template
from flask import current_app as app
@app.route('/')
@app.route('/index')
def index():
return "Hello, World Lets make a party!"
exampledash.py
from dash import Dash
import dash_table
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
def Add_Dash(server):
"""Create Dash app."""
external_stylesheets = ['/static/dist/css/style.css']
external_scripts = ['/static/dist/js/includes/jquery.min.js',
'/static/dist/js/main.js']
dash_app = Dash(server=server,
external_stylesheets=external_stylesheets,
external_scripts=external_scripts,
routes_pathname_prefix='/commands/')
# Create Dash Layout
dash_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': u'Montréal'},
],
'layout': {
'title': 'Dash Data Visualization'
}
}
)
])
return dash_app.server
Uitleg.
Het gaat hier de volgende code
dash_app = Dash(server=server,
external_stylesheets=external_stylesheets,
external_scripts=external_scripts,
routes_pathname_prefix='/commands/')
We pass our Flask instance to
Add_Dash
as a parameter called server. Unlike the previous examples,
its actually server
running the show this time, with Dash piggybacking as a module.
Instead of creating our dash_app
object as a global variable (as is suggested), we stuck in a
function calledAdd_Dash()
. This allows us to pass our top-level Flask app into Dash asserver
,
hence dash_app = Dash(server=server)
.
This effectively spins up a Dash instance using our Flask app at its core, as opposed
to its own!
start flaskapp
python wsgi.py
Deel2 : Meerdere dashboards in een Flask
dit doe je als volgt :
__init__.py
"""Initialize app."""
from flask import Flask
def create_app():
"""Construct the core application."""
server = Flask(__name__,
instance_relative_config=False)
#app.config.from_object('config.Config')
with server.app_context():
from mydashapp2 import routes
from .dash_application import mydash1
app = mydash1.Add_Dash(server)
from .dash_application import mydash2
app = mydash2.Add_Dash(server)
return app
In je subdirectory dash_application zitten je 2 dashboards mydash1.py en mydash2.py
mydash1.py
from dash import Dash
import dash_table
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
def Add_Dash(server):
"""Create Dash app."""
external_stylesheets = ['/static/dist/css/style.css']
external_scripts = ['/static/dist/js/includes/jquery.min.js',
'/static/dist/js/main.js']
dash_app = Dash(server=server,
external_stylesheets=external_stylesheets,
external_scripts=external_scripts,
url_base_pathname=f'/mydash1/')
# Create Dash Layout
dash_app.layout = html.Div(children=[
html.H1(children='Hello Dash 1'),
html.Div(children='''
Dash: Dashboard 1.
'''),
])
return dash_app.server
mydash2
from dash import Dash
import dash_table
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
def Add_Dash(server):
"""Create Dash app."""
external_stylesheets = ['/static/dist/css/style.css']
external_scripts = ['/static/dist/js/includes/jquery.min.js',
'/static/dist/js/main.js']
dash_app = Dash(server=server,
external_stylesheets=external_stylesheets,
external_scripts=external_scripts,
url_base_pathname=f'/mydash2/')
# Create Dash Layout
dash_app.layout = html.Div(children=[
html.H1(children='Hello Dash 2'),
html.Div(children='''
Dash: Dashboard 2.
'''),
])
return dash_app.server
Abonneren op:
Posts (Atom)
Datums bepalen adhv begin en einddatum in Dataframe
Voorbeeld op losse velden ####################################################################### # import necessary packages from datetime...
-
value_counts geef per waarde het aantal voorkomens in een bepaalde df_iris.species.value_counts() versicolor 50 setosa 50 v...
-
import textfiles # Open a file: file file = open('opa.txt','r') # Print it print(file.read()) # Check whether file ...
-
scikit-learn, a standard library for machine learning in Python. It describes itself like this: Machine Learning in Python •Simple and...