问题
I create the following small app with Dash 1.4.0 and Flask 1.0.2, please find it below. I was able to deploy it to Centos Apache server, it starts but the only stuff I get is a loading page, in browser console I see that some components are absent, please see printscreen (I deleted ip of my server in the picture), what should I do to solve the issue? It works in my PC with no problems
Console in Chrome browser:
WebApp Code:
from libs.initsetup import InitSetup
import libs.dbops as dbops
import os
import dash
import dash_core_components as dcc
import dash_html_components as html
from flask_caching import Cache
from flask import Flask
on_server = True
if not on_server:
WORKDIR = ""
else:
WORKDIR = "/var/www/mosregwebsite_dash_plot"
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
server = Flask(__name__)
dash_app = dash.Dash(__name__, server=server)
dash_app.scripts.config.serve_locally = True
dash_app.css.config.serve_locally = True
cache = Cache(dash_app.server, config={
'CACHE_TYPE': 'filesystem',
'CACHE_DIR': WORKDIR + os.path.join(os.getcwd(), 'cache-directory')
})
TIMEOUT = 1800 # plots are updated every 30 minutes
@cache.memoize(timeout=TIMEOUT)
def return_layout():
clients = InitSetup.read_initfile_json(WORKDIR + os.path.join(os.getcwd(), "jsons", "clients.json"))
HOST, DBUSER, DBPASSWORD, AUTH_PLUGIN, *rest = InitSetup.read_mysql_init_config_file(WORKDIR +
os.path.join(os.getcwd(), "mosregwebsite_dash_plot.config.txt"))
conn, curs = dbops.create_mysql_connection(HOST, DBUSER, DBPASSWORD, AUTH_PLUGIN)
graphs = []
for k, v in clients.items():
x, y = dbops.select_data_for_pictures(curs, k)
graphs.append({'x': x, 'y': y, 'type': 'lineplot', 'name': v})
return html.Div(children=[
dcc.Graph(
style={
'textAlign': 'center',
'height': '900px',
},
id='example-graph',
figure={
'data': graphs,
'layout': {
}
}
)
])
dash_app.layout = return_layout
if __name__ == '__main__':
os.mkdir("numbeo")
if not on_server:
dash_app.run_server(host='127.0.0.107', port=8999, debug=False)
else:
HOST, PORT = InitSetup.read_website_settings_from_config_file(
WORKDIR + os.path.join(os.getcwd(),
"mosregwebsite_dash_plot.config.txt"))
dash_app.run_server(host=HOST, port=int(PORT), debug=False)
######### WSGI FILE: ##################
import sys
import os
activate_this = '/var/www/mosregwebsite_dash_plot/env/bin/activate_this.py'
with open(activate_this) as file_:
exec(file_.read(), dict(__file__=activate_this))
sys.path.insert(0, '/var/www/mosregwebsite_dash_plot/')
from mosregwebsite_dash_plot import server as application
####### SETUP.PY ##############
from setuptools import setup
setup(
name='mosreg_webscrap_website',
version='1.0.0',
packages=[''],
url='',
license='',
author='kozyrev.av',
author_email='kozirev8@gmail.com',
description='This is website which display processed information from
mosreg website',
install_requires=[
'dash==1.4.0',
'Flask-Caching==1.7.2',
'mysql-connector==2.2.9',
'mysql-connector-python==8.0.16',
'flask==1.0.2'
]
)
回答1:
https://dash.plot.ly/react-for-python-developers check everything is installed correctly.
To install Node.js, go to the Node.js website to download the latest version. We recommend installing the LTS version.
Node.js will automatically install the Node Package Manager npm on your machine
Verify that node is installed by running: node -v
Verify that npm is installed by running: npm -v
来源:https://stackoverflow.com/questions/58343593/can-t-correctly-deploy-dash-1-4-0-to-centos-apache-server-webpage-stays-in-uplo