Problems with Routing URLs using CGI and Bottle.py
- by Risingson
I've been having difficulty getting anything more than a simple index / to return correctly using bottle.py in a CGI environment. When I try to return /hello I get a 404 response. However, if I request /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())
And here is my .htaccess file
DirectoryIndex index.py
<ifmodule mod_rewrite.c="">
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.py/$1 [L]
</ifmodule>
I copied much of the code from here as I'm using DH and it seemed relevant: http://blog.coderonfire.com/2010/02/running-bottle-python-micro-framework.html
Thanks for helping.