我在OpenShift应用程序中设置了rawdog并安装了Python和cron磁带。我得到应用程序来提供生成的HTML,但是css样式表不可用。
我使用以下wsgi.py文件。
#!/usr/bin/python
import os
SERVE_FILE = os.path.join(os.environ['OPENSHIFT_DATA_DIR'], 'www', 'index.html')
virtenv = os.environ['OPENSHIFT_PYTHON_DIR'] + '/virtenv/'
virtualenv = os.path.join(virtenv, 'bin/activate_this.py')
try:
execfile(virtualenv, dict(__file__=virtualenv))
except IOError:
pass
def application(environ, start_response):
status = '200 OK'
output = open(SERVE_FILE, 'r').read()
response_headers = [('Content-type', 'text/html'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
if __name__ == '__main__':
from wsgiref.simple_server import make_server
httpd = make_server('localhost', 8051, application)
# Wait for a single request, serve it and quit.
httpd.handle_request()
css文件应位于相同的文件夹中。 as index.html,
<link rel="stylesheet" href="style.css" type="text/css">
css文件位于~/app-root/repo/wsgi/static/css/style.css
。
我还有一个~/app-root/repo/wsgi/.htaccess
文件,其中包含:
RewriteEngine on
RewriteRule ^/style.css static/css/style.css [R]
到目前为止,它似乎并没有起作用。关于如何使用Apache在OpenShift上提供静态内容的任何想法?
答案 0 :(得分:0)
您的<link rel="stylesheet" href="style.css" type="text/css">
应该看起来像<link rel="stylesheet" href="static/css/style.css" type="text/css">