Python程序似乎正在运行twi

2024-10-05 14:27:39 发布

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

我有一个运行Flask的python程序。我注意到一个奇怪的事情,它看起来像是程序正在运行两次,这是我不想要的。在

这是启动程序的文件(运行服务器.py,在根文件夹/):

from myapp import app

if __name__ == "__main__":
    print "woho"
    app.run(host='0.0.0.0',debug=True)

运行这个程序时,我可以看到终端中有两个“woho”,表示有什么奇怪的东西。在

在/myapp文件夹中我有一个

^{pr2}$

然后在我的视图.py(同样在/myapp中)我有以下所有视图:

from myapp import app
from flask import render_template

@app.route('/')
def index():
    return render_template('index.html')

Tags: 文件frompyimport程序文件夹视图app