python - 名称错误 : name 'helloworld' is not defined

标签 python apache flask

我的文件如下:

helloworld.py

from flask import Flask
app = Flask(__name__)

@app.route('/')
def __init__(self):
    print 'Hello World!'

if __name__ == '__main__':
    app.run()

应用程序.wsgi

import os
import sys


sys.path.append('/srv/www/mysite.com/application')

os.environ['PYTHON_EGG_CACHE'] = '/srv/www/mysite.com/.python-egg'

import flaskr.helloworld
application = helloworld

当尝试通过我的网络浏览器运行它时,模块加载正常。我最终收到了 500 错误,在我的 error.log 中显示了“NameError: name 'helloworld' is not Defined”

有什么想法吗?

提前谢谢您。

最佳答案

import flaskr.helloworld as helloworld
application = helloworld.app

或者:

import flaskr.helloworld
application = flaskr.helloworld.app

关于python - 名称错误 : name 'helloworld' is not defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8713378/

相关文章:

python - 如何使用 python 更改元素的名称(包括 xml 中的编号)?

apache - 页面加载时将 https 设置为默认值

svn - .htaccess 文件中的 If 语句,仅在特定目录中启用密码保护

http - Microsoft AD 应用程序验证失败 : "microsoft-identity-association.json has a content length that is not set or otherwise invalid"

sql - 使用Flask-SQLAlchemy进行多对多查询

python - Matplotlib Gridspec "Cell"标签

python - python中的弱引用

python - 使用 re.findall 在正则表达式中捕获命名组

java - 如何从 linux 服务器读取 geolitecity 文件路径?

javascript - 当后端在 Flask 中运行时动态填充 html