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.
The problem is that the <ifmodule>
block is not relevant to your Apache server and the directives to mod_rewrite are not working. Start with the following .htaccess
and then if you have a need, add the block according to your current apache version.
DirectoryIndex index.py
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.py/$1 [L]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With