获取以wsgi和passenger运行的Python flask应用程序

问题描述

试图获取一个简单的文件(+ passenger_wsgi)Python Flask应用程序,该应用程序在NameCheap.com上运行。

passenger_wsgi.py:

import imp # I added this line (imp)
import os
import sys
sys.path.insert(0,os.path.dirname(__file__))
"""
# This is what the cPanel created by default:
# Commented out for Now,see below this function
def application(environ,start_response):
    start_response('200 OK',[('Content-Type','text/plain')])
    message = 'It works!\n'
    version = 'Python %s\n' % sys.version.split()[0]
    response = '\n'.join([message,version])
    return [response.encode()]
"""
# This is what I added:
wsgi = imp.load_source('wsgi','main.py')
application = wsgi.app
#app = wsgi.app

main.py:

import flask
appy = flask(__name__)
application = appy
@appy.route('/')
def main():
    return "<h1>Beginning03</h1>"
if __name__ == '__main__':
    appy.run(debug=True)

错误日志:

App 332651 output: File "main.py",line 2,in <module>
App 332651 output: appy = flask(__name__)
App 332651 output: TypeError
App 332651 output: 'module' object is not callable

想法?我想我的问题来自“应用程序”和“ appy”对象的滥用。 是的,我刚接触Python:-)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)