#!/bin/sh

set -e

cat > /etc/apache2/conf-enabled/passenger-wsgi-py3.conf <<EOT
Alias /testwsgi /var/www/testwsgi-py3/public
<Location /testwsgi-py3>
  PassengerPython /usr/bin/python3
  PassengerBaseURI /testwsgi-py3
  PassengerAppRoot /var/www/testwsgi-py3
</Location>
EOT

mkdir /var/www/testwsgi-py3
mkdir /var/www/testwsgi-py3/public
mkdir /var/www/testwsgi-py3/tmp
cat > /var/www/testwsgi-py3/passenger_wsgi.py <<EOT
def application(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/plain')])
    return [b"hello world\n"]
EOT
chown -R www-data:www-data /var/www/testwsgi-py3

a2enmod passenger
service apache2 reload

$(dirname $0)/expect-hello-world http://localhost/testwsgi-py3/
