title: Jelastic Apache+mod_wsgi: 'module' object is not callable
body: <p>I have unsuccessfully tried to install my Flask application to a Jelastic server. I have there Apache 2.4 and Python 3.5. The problem shows as a <em>500 Internal Server Error</em> when I try to access my "/" page.</p>
  
  <p><strong>[Point 1.]</strong> When restarting the Apache server, <em>apache2-python : actions</em> page shows some wrong values:</p>
  
  <pre><code> Starting Python 2.4 cartridge (Apache+mod_wsgi)
   Application directory /opt/repo/ROOT selected as DocumentRoot
   $OPENSHIFT_PYTHON_WSGI_APPLICATION=/opt/repo//ROOT/application file not found
    WSGI application was not found
  </code></pre>
  
  <p>I think application directory should be <code>/opt/repo/ROOT/stk_server</code>, which I have defined in /opt/shared/conf/etc/conf.d/openshift.conf:</p>
  
  <pre><code>ServerRoot "/opt/repo/"
  DocumentRoot "/opt/repo/ROOT/stk-server"
  WSGIScriptAlias / "/opt/repo/ROOT/stk_server.wsgi"
  </code></pre>
  
  <p>Why this does not apply when stating Apache? (In different manuals these paths are set in /etc/apache2/sites-available/ directory, but Jelastic environment doesn't have such.)</p>
  
  <p><strong>[Point 2.]</strong> my <code>/opt/shared/webroot/ROOT/stk_server.wsgi</code> file imports my application <code>/opt/shared/webroot/ROOT/stk_server/hello.py</code> using commands</p>
  
  <pre><code>#!/usr/bin/python
  import sys
  import logging
  logging.basicConfig(stream=sys.stderr)
  sys.path.insert(0,"/opt/repo/ROOT/stk_server")
  import os
  os.chdir("/opt/repo/ROOT/stk_server")
  from stk_server import hello as application
  </code></pre>
  
  <p>The <code>hello.py</code> is like this:</p>
  
  <pre><code>from flask import Flask
  app = Flask(__name__)
  
  print("Running my hello.py={}.".format(__name__))
  print("My app={}.".format(app))
  
  @app.route("/")
  def hello():
      return "Hello, I love Python!"
  
  if __name__ == "__main__":
      print ("Starting my hello.__main__")
      app.run()
  </code></pre>
  
  <p>The <code>error_log</code> shows these wsgi:errors:</p>
  
  <pre><code>Running my hello.py=stk_server.hello. 
  My app=&lt;Flask 'stk_server.hello'&gt;. 
  [remote 10...:228] mod_wsgi (pid=27564): Exception occurred processing WSGI script '/opt/repo/ROOT/stk_server.wsgi'. 
  [remote 10...:228] TypeError: 'module' object is not callable 
  [remote 10...:236] mod_wsgi (pid=27565): Exception occurred processing WSGI script '/opt/repo/ROOT/stk_server.wsgi'. 
  [remote 10...:236] TypeError: 'module' object is not callable 
  [remote 10...:228] mod_wsgi (pid=27564): Exception occurred processing WSGI script '/opt/repo/ROOT/stk_server.wsgi'. 
  [remote 10...:228] TypeError: 'module' object is not callable
  </code></pre>
  
  <p>What is this 'module' object? The same error occurs, when the project directory <code>/opt/shared/webroot/ROOT/stk_server</code> has a <code>__init__.py</code> file or not.</p>