让Python flask应用程序与wsgi和passenger一起运行

2024-04-18 01:02:42 发布

您现在位置:Python中文网/ 问答频道 /正文

尝试在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相当陌生:-)


Tags: pyimportapp应用程序wsgioutputapplicationis

热门问题