我正在使用 Bottle 通过 apache 提供测试文件。
以下是我的 apache 配置:
WSGIDaemonProcess temp user=www-data group=www-data processes=1 threads=5
WSGIScriptAlias /temp /opt/gridops/usage/temp/adapter.wsgi
<Directory /opt/gridops/usage/temp>
WSGIProcessGroup temp
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
adapter.wsgi
:
import os,sys
os.chdir(os.path.dirname(__file__))
sys.path = ['/opt/gridops/usage/temp'] + sys.path
os.chdir(os.path.dirname(__file__))
sys.stdout = sys.stderr
import bottle
print "++"*10
import index # This loads your application
application = bottle.default_app()
index.py
:
from bottle import mount, run
from routes import app
from bottle import default_app
default_app.push(app)
#run()
#run(app=app, host='192.168.1.3', port=8085)
routes.py
:
from bottle import Bottle , run,route,static_file,view,template,post,request
app = Bottle()
print str(dir(app))
@app.route('/static/<filename>')
def server_static(filename):
return static_file(filename, root='static')
@app.route('/')
def index():
return template('template',text='This is index page!')
template.tpl
:
<html>
<head>
<link rel="stylesheet" type="text/css" href="static/prettify.css" />
</head>
<body>
{{text}}
</body>
</html>
目录列表
temp/
adapter.wsgi
index.py
routes.py
static/
prettify.css
views/
template.tpl
我的问题是,每当我尝试使用http://192.168.1.3/temp
网页访问 Bottle 应用程序时,都会显示没有静态文件,但每当我访问http://192.168.1.3/temp/
[请注意额外内容/
] 时,页面都会正确加载。我应该做哪些修改以使两者的结果
http://192.168.1.3/temp
变得http://192.168.1.3/temp/
相同?
任何帮助都会非常有帮助