Pregunta

He estado teniendo dificultades para conseguir algo más que un simple índice / a devolver correctamente utilizando bottle.py en un entorno CGI. Cuando trato de volver / hola tengo una respuesta 404. Sin embargo, si solicito /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())

Y aquí está mi archivo .htaccess

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

Me copió gran parte del código de aquí lo estoy usando DH y parecía relevante: http://blog.coderonfire.com/2010/02/running-bottle-python-micro-framework.html

Gracias por ayudarnos.

¿Fue útil?

Solución

El problema es que el bloque <ifmodule> no es relevante para el servidor Apache y las directrices a mod_rewrite no están funcionando. Comenzar con la siguiente .htaccess y luego, si usted tiene una necesidad, añadir el bloque de acuerdo con la versión actual de Apache.

DirectoryIndex index.py
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.py/$1  [L]
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top