尝试在namescape.com上运行简单的一个文件(+passenger_wsgi)Python Flask应用程序
乘客_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
想法?我想我的问题来自于对“应用程序”和“应用程序”对象的错误使用。 是的,我对Python相当陌生:-)
目前没有回答
相关问题 更多 >
编程相关推荐