小编Ris*_*son的帖子

使用CGI和Bottle.py路由URL的问题

在CGI环境中使用bottle.py时,我一直很难获得除简单索引之外的任何东西.当我尝试返回/你好时,我收到了404响应.但是,如果我请求/index.py/hello

import bottle
from bottle import route

@route('/')
def index():
    return 'Index'

@route('/hello')
def hello():
    return 'Hello'

if __name__ == '__main__':
    from wsgiref.handlers import CGIHandler
    CGIHandler().run(bottle.default_app())
Run Code Online (Sandbox Code Playgroud)

这是我的.htaccess文件

DirectoryIndex index.py
<ifmodule mod_rewrite.c="">
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.py/$1  [L]
</ifmodule>
Run Code Online (Sandbox Code Playgroud)

我从这里复制了大部分代码,因为我正在使用DH,它似乎相关:http://blog.coderonfire.com/2010/02/running-bottle-python-micro-framework.html

谢谢你的帮助.

python .htaccess cgi bottle

6
推荐指数
1
解决办法
3012
查看次数

标签 统计

.htaccess ×1

bottle ×1

cgi ×1

python ×1