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 500 Internal Server Error when I try to access my "/" page.
[Point 1.] When restarting the Apache server, apache2-python : actions page shows some wrong values:
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
I think application directory should be /opt/repo/ROOT/stk_server
, which I have defined in /opt/shared/conf/etc/conf.d/openshift.conf:
ServerRoot "/opt/repo/"
DocumentRoot "/opt/repo/ROOT/stk-server"
WSGIScriptAlias / "/opt/repo/ROOT/stk_server.wsgi"
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.)
[Point 2.] my /opt/shared/webroot/ROOT/stk_server.wsgi
file imports my application /opt/shared/webroot/ROOT/stk_server/hello.py
using commands
#!/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
The hello.py
is like this:
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()
The error_log
shows these wsgi:errors:
Running my hello.py=stk_server.hello.
My app=<Flask 'stk_server.hello'>.
[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
What is this 'module' object? The same error occurs, when the project directory /opt/shared/webroot/ROOT/stk_server
has a __init__.py
file or not.