我尝试将Flask应用程序安装到Jelastic服务器上失败了。我有Apache 2.4和Python 3.5。当我尝试访问我的" /"时,问题显示为 500内部服务器错误页。
[第1点]。重启Apache服务器时, apache2-python:actions 页面显示了一些错误的值:
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
我认为应用程序目录应该是/opt/repo/ROOT/stk_server
,我已在/opt/shared/conf/etc/conf.d/openshift.conf中定义:
ServerRoot "/opt/repo/"
DocumentRoot "/opt/repo/ROOT/stk-server"
WSGIScriptAlias / "/opt/repo/ROOT/stk_server.wsgi"
为什么在说Apache时这不适用? (在不同的手册中,这些路径在/ etc / apache2 / sites-available /目录中设置,但是Jelastic环境没有这样的路径。)
[第2点。] 我的/opt/shared/webroot/ROOT/stk_server.wsgi
文件使用命令导入我的应用/opt/shared/webroot/ROOT/stk_server/hello.py
#!/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
hello.py
是这样的:
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()
error_log
显示了这些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
这是什么模块&#39;宾语?当项目目录/opt/shared/webroot/ROOT/stk_server
具有__init__.py
文件时,会发生同样的错误。
答案 0 :(得分:0)
我们检查了您的环境,发现stk_server.wsgi文件中导入的“app”不正确。 正确的方法:
node --inspect --debug-brk /usr/local/bin/gulp compilecss
祝你有个美好的一天,Jelastic Support!