title: How to get apache to serve static files on Flask webapp
body: <p>I'm getting a 500 internal error while trying to get Apache to serve my static files.</p>
  
  <p>The application will be locally hosted (not www facing). There will be no DNS to resolve a 'www.domain.com' name. I want to be able to access the application by entering the IP address of the server when I'm on that network.</p>
  
  <p>This is my httpd.conf file (I'm on RHEL):</p>
  
  <pre><code>&lt;Directory /var/www/testapp&gt;
    Order allow,deny
    Allow from all
  &lt;/Directory&gt;
  
  WSGIScriptAlias / /var/www/testapp/service.wsgi
  </code></pre>
  
  <p>If I change the WSGIScriptAlias  to <code>WGSIScriptAlias /test /var/www/testapp/service.wsgi</code> then I can view my static files when I type in the IP, but I still can't access the service.py script from [IP]/test.</p>
  
  <p>In any case, I want to be able to service all GET/POST requests with the service.py script so I want my alias to start at <code>/</code>, not some other place.</p>
  
  <p>All my static files are in /var/www/html (Apache was automatically displaying these files before I messed with the httpd.conf, now I'm just getting a 500).</p>
  
  <p>This is my service.wsgi:</p>
  
  <pre><code>import sys
  sys.path.insert(0, '/var/www/testapp')
  from service import app as application
  </code></pre>
  
  <p>This is my service.py:</p>
  
  <pre><code>from flask import Flask
  app = Flask(__name__)
  
  @app.route("/")
  def hello(environ, start_response):
      status = '200 OK'
      output = "Hello"
      response_headers = [('Content-type', 'text/plain'), ('Content-length', str(len(output)))]
      start_response(status, response_headers)
      return output
  
  if __name__=='__main__'
      app.run()
  </code></pre>
  
  <p>Do I need keep my .wsgi files in the /var/www/html directory as well? Or can they go in a different folder? I can see that there might be some conflict between the message I am sending to the server ('Hello') and the static files that are already in the /var/www/html/ directory. That's why I tried setting the alias to <code>/test</code> but that didn't work either.</p>
  
  <p>I just want my Flask application to service GET/POST requests and want apache to serve all the static files.</p>