• <tfoot id='N74p4'></tfoot>
      <bdo id='N74p4'></bdo><ul id='N74p4'></ul>

    <i id='N74p4'><tr id='N74p4'><dt id='N74p4'><q id='N74p4'><span id='N74p4'><b id='N74p4'><form id='N74p4'><ins id='N74p4'></ins><ul id='N74p4'></ul><sub id='N74p4'></sub></form><legend id='N74p4'></legend><bdo id='N74p4'><pre id='N74p4'><center id='N74p4'></center></pre></bdo></b><th id='N74p4'></th></span></q></dt></tr></i><div id='N74p4'><tfoot id='N74p4'></tfoot><dl id='N74p4'><fieldset id='N74p4'></fieldset></dl></div>

    1. <small id='N74p4'></small><noframes id='N74p4'>

      <legend id='N74p4'><style id='N74p4'><dir id='N74p4'><q id='N74p4'></q></dir></style></legend>

        Flask 视图引发 TypeError:'bool' 对象不可调用

        Flask view raises TypeError: #39;bool#39; object is not callable(Flask 视图引发 TypeError:bool 对象不可调用)
          <bdo id='LbHxy'></bdo><ul id='LbHxy'></ul>

              <i id='LbHxy'><tr id='LbHxy'><dt id='LbHxy'><q id='LbHxy'><span id='LbHxy'><b id='LbHxy'><form id='LbHxy'><ins id='LbHxy'></ins><ul id='LbHxy'></ul><sub id='LbHxy'></sub></form><legend id='LbHxy'></legend><bdo id='LbHxy'><pre id='LbHxy'><center id='LbHxy'></center></pre></bdo></b><th id='LbHxy'></th></span></q></dt></tr></i><div id='LbHxy'><tfoot id='LbHxy'></tfoot><dl id='LbHxy'><fieldset id='LbHxy'></fieldset></dl></div>
              <tfoot id='LbHxy'></tfoot>

              <small id='LbHxy'></small><noframes id='LbHxy'>

                <tbody id='LbHxy'></tbody>
              1. <legend id='LbHxy'><style id='LbHxy'><dir id='LbHxy'><q id='LbHxy'></q></dir></style></legend>
                • 本文介绍了Flask 视图引发 TypeError:'bool' 对象不可调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  I am trying to debug a view in my Flask app that is return a 500 status with the error TypeError: 'bool' object is not callable in the traceback. The view calls login_user from Flask-Login then returns True to indicate that the login was successful.

                  I have debugged until app_iter = app(environ, start_response) and the app is now a boolean with the value True rather than the Flask app object.

                  Traceback (most recent call last):
                    File "D:Python27libsite-packagesflaskapp.py", line 1836, in __call__
                      return self.wsgi_app(environ, start_response)
                    File "D:Python27libsite-packagesflaskapp.py", line 1820, in wsgi_app
                      response = self.make_response(self.handle_exception(e))
                    File "D:Python27libsite-packagesflaskapp.py", line 1403, in handle_exception
                      reraise(exc_type, exc_value, tb)
                    File "D:Python27libsite-packagesflaskapp.py", line 1817, in wsgi_app
                      response = self.full_dispatch_request()
                    File "D:Python27libsite-packagesflaskapp.py", line 1478, in full_dispatch_request
                      response = self.make_response(rv)
                    File "D:Python27libsite-packagesflaskapp.py", line 1577, in make_response
                      rv = self.response_class.force_type(rv, request.environ)
                    File "D:Python27libsite-packageswerkzeugwrappers.py", line 824, in force_type
                      response = BaseResponse(*_run_wsgi_app(response, environ))
                    File "D:Python27libsite-packageswerkzeugwrappers.py", line 57, in _run_wsgi_app
                      return _run_wsgi_app(*args)
                    File "D:Python27libsite-packageswerkzeug	est.py", line 854, in run_wsgi_app
                      app_iter = app(environ, start_response)
                  TypeError: 'bool' object is not callable
                  

                  @app.route('/login', methods=['POST'])
                  def login():
                      username = request.form['username']
                      user = User.query.filter_by(username=username).first()
                  
                      if user:
                          login_user(user)
                          return True
                  
                      return False
                  

                  解决方案

                  In Flask, a view must return one of the following:

                  • a string
                  • a Response object (or subclass)
                  • a tuple of (string, status, headers) or (string, status)
                  • a valid WSGI application

                  Flask tests for the first 3 options, and if they don't fit, assumes it is the fourth. You returned True somewhere, and it is being treated as a WSGI application instead.

                  See About Responses in the documentation.

                  这篇关于Flask 视图引发 TypeError:'bool' 对象不可调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
                  Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
                  Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
                  Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
                  Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)
                  Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)
                    <tbody id='gl0jx'></tbody>
                • <tfoot id='gl0jx'></tfoot><legend id='gl0jx'><style id='gl0jx'><dir id='gl0jx'><q id='gl0jx'></q></dir></style></legend>
                  <i id='gl0jx'><tr id='gl0jx'><dt id='gl0jx'><q id='gl0jx'><span id='gl0jx'><b id='gl0jx'><form id='gl0jx'><ins id='gl0jx'></ins><ul id='gl0jx'></ul><sub id='gl0jx'></sub></form><legend id='gl0jx'></legend><bdo id='gl0jx'><pre id='gl0jx'><center id='gl0jx'></center></pre></bdo></b><th id='gl0jx'></th></span></q></dt></tr></i><div id='gl0jx'><tfoot id='gl0jx'></tfoot><dl id='gl0jx'><fieldset id='gl0jx'></fieldset></dl></div>

                        <bdo id='gl0jx'></bdo><ul id='gl0jx'></ul>
                      • <small id='gl0jx'></small><noframes id='gl0jx'>