如何在 Apache 服务器上托管 Dash 应用程序?

How do I host a Dash app on an Apache Server?

我刚开始托管 Raspberry Pi Apache 服务器,我有一个简单的 Dash application I would like to host via a .wsgi file. Following Flask's official documentation, post's answer, modwsgi's documentation, and this 指南可以将 Flask 连接到 Apache;我能够让我的文件和结构达到下面的状态,但是导航到 http://#.#.#.#/dash returns 404,而 http://#.#. #.# 导航到默认的 Apache 页面。我确定我遗漏了一些东西,而且它相对简单,我只是不确定是什么。 apache错误日志没有错误和异常。

dash.py

from datetime import date
import dash
import dash_table
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd

import data_controller as dc

external_stylesheets = ['/style.css']

data = dc.Data()

app = dash.Dash(__name__, external_stylesheets=external_stylesheets, requests_pathname_prefix='/dash/')
server = app.server

def serve_layout():
    data = dc.Data()

    today = date.today()

    df = data.display_data()

    return dcc.Tabs([
        html.H1([children='Hello Apache!']),
        dash_table.DataTable(columns=[{'name':i,'id':i} for i in df.columns],data=df.loc[:].to_dict('records'))
    ])

app.layout = serve_layout

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

/etc/apache2/sites-available/dash.conf

WSGIDaemonProcess dash user=pi group=pi home=/home/pi/Documents/programming/ threads=5
WSGIScriptAlias /dash /var/www/html/wsgi/dash.wsgi

WSGIProcessGroup dash
WSGIApplicationGroup %{GLOBAL}

/var/www/html/wsgi/dash.wsgi

#!/usr/bin/python
import sys
sys.path.insert(0,'/home/pi/Documents/programming/dashboard/')
from dash import server as application

正如所料,答案很简单,只是在我使用的资源中并不明显。 This 演练提醒我需要使用命令 sudo /usr/sbin/a2ensite dash.conf

a2ensite 和我的 .config 文件之间建立虚拟路径