我是托管 Raspberry Pi Apache 服务器的新手,我想通过 .wsgi 文件托管一个简单的 Dash 应用程序。按照 Flask 的 official documentation、this 帖子的回答、modwsgi 的 documentation 和 this 指南将 Flask 连接到 Apache;我能够让我的文件和结构处于下面的状态,但导航到 http://#.#.#.#/dash 返回 404,而 http://#.#.#.# 导航到默认的 Apache 页面。我确定我遗漏了一些东西,而且它相对简单,我只是不确定是什么。 apache错误日志没有错误或异常。
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')
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}
#!/usr/bin/python
import sys
sys.path.insert(0,'/home/pi/Documents/programming/dashboard/')
from dash import server as application
答案 0 :(得分:0)
正如所料,答案很简单,只是在我使用的资源中并不明显。 This 演练提醒我需要使用命令 a2ensite
sudo /usr/sbin/a2ensite dash.conf
和我的 .config 文件之间建立虚拟路径