apache中的mod_wsgi未正确呈现html根目录



我有下面的python脚本,它会拉入我的index.html,它最终会被拆分为header.html和footer.html,然后python代码会组成正文。我如何告诉python使站点目录成为所有html和html相关文件的根目录,以便css和img文件夹正确呈现?

#!/usr/bin/env python
import os
def application(environ, start_response):
status = '200 OK'
localpath = os.path.dirname(__file__)
index_file = 'index.html'
index_path = os.path.join(localpath, "adminUI", index_file)
with open(index_path, 'rb') as index:
output = index.read()
#output = b'Hello World!n'
response_headers = [('Content-type', 'text/html'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]

没关系,将Alias添加到虚拟httpd.conf解决了问题:

Alias /img /usr/local/apache2/site/img
Alias ../vendors /usr/local/apache2/vendors

最新更新