【发布时间】: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