首页 > 解决方案 > 使用 windowsapi reloader 重启

问题描述

我运行我的烧瓶代码。起初,没关系,但有时它不起作用,我得到了这个错误:

使用 windowsapi reloader 重启

我的代码:

x = pd.read_csv('clas.csv')

app = Flask(__name__) 

@app.route('/<x>') 
class QuotesView(FlaskView):
    def index(self):  
        return "<br>".join(x)
QuotesView.register(app)
     
if __name__ == '__main__':
    app.run(debug=False)

标签: pythonflask

解决方案


@app.route('/<x>') 
class QuotesView(FlaskView):
    def index(self):  
        return "<br>".join(x) QuotesView.register(app)

当然,这不是问题,你改变了一些东西,我认为原始代码是

@app.route('/<x>') 
def index(self):  
   return "<br>".join(x) QuotesView.register(app)

然后你决定将这个函数包含在一个类中class QuotesView(FlaskView),这样就不会像以前那样了。

是不是?:)

根据以下评论

问题中的代码给出了错误消息NameError: name 'FlaskView' is not defined,而不是您提到的错误消息,所以肯定有一些改变。


推荐阅读