【问题标题】:mod_wsgi in apache not rendering html root properlyapache 中的 mod_wsgi 无法正确呈现 html 根目录
【发布时间】:2020-09-03 05:24:19
【问题描述】:

我有以下 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]

【问题讨论】:

    标签: python-3.x apache mod-wsgi


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-29
      • 1970-01-01
      • 1970-01-01
      • 2015-11-28
      • 1970-01-01
      • 2012-08-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多