Python WSGI handler directly in Apache .htaccess, not in VirtualHost
Asked Answered
J

1

1

I know how to have a Python Bottle server:

import os
from bottle import route, template, default_app
os.chdir(os.path.dirname(__file__))

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

application = default_app()

run with WSGI, configured like this with Apache:

<VirtualHost *:80>
  ServerName example.com
  <Directory />
    AllowOverride All
    Require all granted
  </Directory>
  WSGIScriptAlias / /var/www/wsgi_test/app.wsgi
</VirtualHost>

Is it possible to do the WSGI configuration directly in the .htaccess?

Japan answered 27/11, 2019 at 22:37 Comment(0)
J
1

I just found the doc, and it seems that the answer is no, sadly:

When using mod_cgi to host CGI applications, this would be done using the ScriptAlias directive. For mod_wsgi, the directive is instead called WSGIScriptAlias:

WSGIScriptAlias /myapp /usr/local/www/wsgi-scripts/myapp.wsgi

This directive can only appear in the main Apache configuration files. The directive can be used at server scope but would normally be placed within the VirtualHost container for a particular site. It cannot be used within either of the Location, Directory or Files container directives, nor can it be used within a “.htaccess” file.

(emphasis mine)

Japan answered 27/11, 2019 at 23:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.