title: Serving a "Hello World" page using Flask and Apache/mod_wsgi on Ubuntu server
body: <p><em>NOTE: I've found five questions regarding broken "hello world on flask/mod_wsgi" implementations. I have looked through all of them, and can't find the solution to my own broken implementation.  So please don't be too hasty to close this question as a duplicate.</em></p>
  
  <p>I'm administering a cloud Ubuntu VM. Currently it's running a LAMP stack. In my webroot I've got a mediawiki and a few HTML files like <a href="http://pipad.org/ball/multiball.html" rel="nofollow">http://pipad.org/ball/multiball.html</a> -- everything is running okay.</p>
  
  <p>Now I'm trying to have <a href="http://pipad.org/foo" rel="nofollow">http://pipad.org/foo</a> serve a page dynamically generated by a Python backend, using Flask and Apache/mod_wsgi.</p>
  
  <p>Unfortunately navigating my browser to <a href="http://pipad.org/foo" rel="nofollow">http://pipad.org/foo</a> results in "URL not found".</p>
  
  <p>Here are my files:</p>
  
  <pre><code>pi@PiDroplet:~/web/piFlask$ pwd
  /home/pi/web/piFlask
  
  pi@PiDroplet:~/web/piFlask$ ls -l
  total 24
  -rw-r--r-- 1 root root  628 May 15 02:37 apache.conf
  -rwxrwxr-x 1 pi   pi    153 May 15 02:39 piFlask.py
  -rwxrwxr-x 1 pi   pi    379 May 15 02:38 piFlask.wsgi
  drwxrwxr-x 5 pi   pi   4096 May 14 09:06 venv
  </code></pre>
  
  <p><strong>piFlask.py</strong></p>
  
  <pre><code>from flask import Flask
  app = Flask(__name__)
  
  @app.route('/')
  def hello_world():
      return 'Hello World!'
  
  # if __name__ == '__main__':
  #    app.run()
  </code></pre>
  
  <p><strong>piFlask.wsgi</strong></p>
  
  <pre><code># http://flask.pocoo.org/docs/0.10/deploying/mod_wsgi/#creating-a-wsgi-file
  # http://www.enigmeta.com/2012/08/16/starting-flask/
  
  import os, sys
  
  PROJECT_DIR = '/home/pi/web/piFlask'
  
  activate_this = os.path.join(PROJECT_DIR, 'bin', 'activate_this.py')
  execfile(activate_this, dict(__file__=activate_this))
  sys.path.insert(0, PROJECT_DIR)
  
  from piFlask import app as application
  </code></pre>
  
  <p><strong>apache.conf</strong></p>
  
  <pre><code>pi@PiDroplet:~/web/piFlask$ cat apache.conf 
  # Look in http://wiki.apache.org/httpd/DistrosDefaultLayout &amp; find equiv to /usr/local/apache2/conf/httpd.conf
  # for me (Ubuntu) it's /etc/apache2/apache2.conf
  #
  # append: 
  #    Include /path/to/this/file
  
  # http://flask.pocoo.org/docs/0.10/deploying/mod_wsgi/#configuring-apache
  &lt;VirtualHost *&gt;
      ServerName pipad.org
  
      WSGIDaemonProcess piFlask user=pi group=pi threads=5
      WSGIScriptAlias /foo /home/pi/web/piFlask/piFlask.wsgi
  
      &lt;Directory /home/pi/web/piFlask&gt;
          WSGIProcessGroup piFlask
          WSGIApplicationGroup %{GLOBAL}
          Order deny,allow
          Allow from all
      &lt;/Directory&gt;
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>And as per the comment in the above config file, ...</p>
  
  <pre><code>pi@PiDroplet:~/web/piFlask$ tail -n 2 /etc/apache2/apache2.conf 
  
  Include /home/pi/web/piFlask/apache.conf
  </code></pre>
  
  <p>Can anyone see what I'm missing?</p>