I've been following the instructions on http://flask.pocoo.org/docs/0.11/deploying/mod_wsgi/ to get my Flask application to be deployed on Apache through WSGI on a Raspberry Pi running Raspbian, but whatever I try, I keep getting a 404-error on the location I've specified. I used the info on various webpages I could find (especially the instructions on http://www.ashokraja.me/post/Serving-a-Python-Flask-Web-Application-via-Apache-Webserver-in-Raspberry-Pi.aspx), but nothing seems to work out.
Logged in as root, I created a directory /var/www/flasktest
in which I put two files:
flasktest.py
, containing:
#!/usr/bin/python
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == '__main__':
app.run()
and flasktest.wsgi
containing:
#!/usr/bin/python
import sys
sys.path.insert(0, '/var/www/flasktest')
from flasktest import app as application
I then did a chmod ugo+x
on both files (don't know if that's necessary, though).
I also created /etc/apache2/sites-available/001-flasktest.conf
containing
<VirtualHost *:80>
ServerName localhost
WSGIDaemonProcess flasktest threads=5
WSGIScriptAlias /flasktest/ /var/www/flasktest/flasktest.wsgi
<Directory /var/www/flask/flasktest>
WSGIProcessGroup flasktest
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
I executed a2enmod wsgi
, a2ensite 001-flasktest.conf
and service apache2 reload
. Every command was executed as root user.
When I go now go to http://localhost/flasktest
I get a 404-error. http://localhost
gives me the default Apache-page, so apparently Apache is running correctly. As far as I can see, Apache does not generate any error messages at all.
I really don't know what goes wrong: what makes the 404 come up? Can somebody help me out here? Thanks in advance!