本文介绍了无法将Dash 1.4.0正确部署到CentOS Apache服务器,网页保持上传状态,为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Dash 1.4.0和Flask 1.0.2创建以下小型应用程序,请在下面找到它.我能够将其部署到Centos Apache服务器,它启动了,但是我得到的唯一东西是一个加载页面,在浏览器控制台中,我看到某些组件不存在,请参见printscreen(我在图中删除了我服务器的ip),我应该怎么做才能解决这个问题?它可以在我的PC上正常工作

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

Chrome浏览器中的控制台:

Console in Chrome browser:

WebApp代码:

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'
        ]
    )

推荐答案

https://dash.plot.ly/react-for-python-developers 检查一切是否正确安装.

https://dash.plot.ly/react-for-python-developers check everything is installed correctly.

这篇关于无法将Dash 1.4.0正确部署到CentOS Apache服务器,网页保持上传状态,为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 07:59
查看更多