0

I followed all docs to install mod_wsgi correctly under win. Happily the Flask python hello world program runs smoothly! however, instead of flask, I need to use dash. I use a demo dash program from their website, also runs smoothly in VSCODE with the development webserver under localhost:8050. So far so good. I've tried to configure everything correctly now for use dash with WSGI on Apache 2.4. Apache starts smoothly, no error messages at all. However, when calling the website through apache, it starts with the "loading...." from dash, but then nothing follows. looking into the chrome console, I can see many errors like ERR_NAME_NOT_RESOLVED for many dash dependencies. Thus, it seems that when running on apache the dash dependencies are not found. I've tried all workaround I could find from 10... of website, all dont work for me so for.... hope someone has a good idea here.... a bit frustrating... please find below the code segments... THANKS!!!!!!!!!

the app3.py is in directory: e:/quantconnect_lean21/data/Cryptohopper_API_apps/app_test_flask/

the app3.py:

`# -*- coding: utf-8 -*-

# Run this app with python app.py and
# visit http://127.0.0.1:8050/ in your web browser.

import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.express as px
import pandas as pd
from flask import Flask

external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']


app = dash.Dash(__name__)

server = app.server
app.scripts.config.serve_locally = True
app.css.config.serve_locally = True




# assume you have a "long-form" data frame
# see https://plotly.com/python/px-arguments/ for more options
df = pd.DataFrame({
    "Fruit": ["Apples", "Oranges", "Bananas", "Apples", "Oranges", "Bananas"],
    "Amount": [4, 1, 2, 2, 4, 5],
    "City": ["SF", "SF", "SF", "Montreal", "Montreal", "Montreal"]
})

fig = px.bar(df, x="Fruit", y="Amount", color="City", barmode="group")

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=fig
    )
])


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

========================================================== This is the yourapplication.wsgi in the same dir as the py file

import sys
sys.path.insert(0, 'e:/quantconnect_lean21/data/Cryptohopper_API_apps/app_test_flask/')
sys.path.append("e:/ProgrammingSoftware/Python39/Lib/site-packages;e:/quantconnect_lean21/data/Cryptohopper_API_apps/app_test_flask")

from app3 import app
application = server

============================================================ This is the apache vhost file:

<VirtualHost *>
ServerAdmin webmaster@localhost
ServerName localhost
WSGIScriptAlias / "e:/quantconnect_lean21/data/Cryptohopper_API_apps/app_test_flask/yourapplication.wsgi" 
##\
##   process-group=app_test_flask application-group=%{GLOBAL}
DocumentRoot "E:/quantconnect_lean21/data/Cryptohopper_API_apps/app_test_flask"
<Directory "e:/quantconnect_lean21/data/Cryptohopper_API_apps/app_test_flask">
        Order deny,allow
        Allow from all
        Require all granted

</Directory>
AddHandler wsgi-script .wsgi
WSGIScriptReloading On

WSGIApplicationGroup %{GLOBAL}
ErrorLog "e:/quantconnect_lean21/data/Cryptohopper_API_apps/app_test_flask/error.log"
CustomLog "e:/quantconnect_lean21/data/Cryptohopper_API_apps/app_test_flask/access.log" common
</VirtualHost>

=================================================== typical errors from the console:

GET http://_dash-component-suites/dash/deps/polyfill@7.v1_21_0m1629874495.12.1.min.js net::ERR_NAME_NOT_RESOLVED localhost/:21 GET http://_dash-component-suites/dash/deps/react@16.v1_21_0m1629874495.14.0.min.js net::ERR_NAME_NOT_RESOLVED

4

0 回答 0