flask app only shows list of files with apache2
Question: Im trying to host a flask app with an apache2 server. The server works but I'm
only seeing a list of files, the wonderful "index of" page. My code is pretty
simple. This is my hello.py file in /var/www/flask_dev:

    
    
    from flask import Flask
    app = Flask(__name__)
    
    @app.route('/')
    def hello_world():
    return 'Hello World!'
    
    if __name__ == '__main__':
        app.run(host='0.0.0.0')
    

I also created an apache config file located in /etc/apache2/sites-
available/flask_dev.conf:

    
    
    ServerName example.com
    
    <VirtualHost *:80>
    
            ServerAdmin webmaster@localhost
            WSGIDaemonProcess hello user=www-data group=www-data threads=5     python-path=/var/www/flask_dev
            WSGIScriptAlias / /var/www/flask_dev/start.wsgi
            <Directory /var/www/flask_dev>
                    WSGIProcessGroup hello
                    WSGIApplicationGroup %{GLOBAL}
                    Options Indexes FollowSymLinks
                    AllowOverride None
                    Require all granted
            </Directory>
    
            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>
    

And the needed wsgi file also located in /var/www/flask_dev/start.wsgi:

    
    
    from hello import app as application
    
    import sys
    sys.stdout = sys.stderr
    

I'm not sure what I did wrong, I just followed a simple tutorial.

Thanks for your help :)


Answer: You probably did not install `mod_wsgi` module for Apache.

<http://flask.pocoo.org/docs/0.10/deploying/mod_wsgi/>

Apache needs to import the `mod_wsgi` module for it to work with python.
Further instructions for installation can be found at.

<https://code.google.com/p/modwsgi/wiki/QuickInstallationGuide>

Once installed, edit your `httpd.conf` with `LoadModule wsgi_module
modules/mod_wsgi.so`

If you are on Windows, you will have to download the appropriate `mod_wsgi.so`
for the python version and architecture. Rename the file to `mod_wsgi.so` if
it has any python specific version naming and set conf to LoadModule.

