Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 属性错误:';功能';对象没有属性';方法';_Python_Html_Python 3.x_Authentication_Flask - Fatal编程技术网

Python 属性错误:';功能';对象没有属性';方法';

Python 属性错误:';功能';对象没有属性';方法';,python,html,python-3.x,authentication,flask,Python,Html,Python 3.x,Authentication,Flask,我有一个网络srv,这是我登录的方式 @app.route('/do_login', methods=['GET','POST']) def do_login(): if request.method == 'POST': email = request.form['email'] password = request.form['password'] 因此,当我运行应用程序并尝试登录时,我收到错误“AttributeError:“function”对象没有属性“method”

我有一个网络srv,这是我登录的方式

@app.route('/do_login', methods=['GET','POST'])
def do_login():
if request.method == 'POST':
    email = request.form['email']
    password = request.form['password']
因此,当我运行应用程序并尝试登录时,我收到错误“AttributeError:“function”对象没有属性“method”

这也是我的html页面

<div class="row">
    <form action="{{ url_for('do_login') }}" method="POST" enctype="multipart/form-data">
        <p>
            <input type="text" name="email" placeholder="exmple@ex.it">
            <input type="password" name="password" placeholder="*****">
            <input type="submit" value="Login">
            <a class = "nav-link" href="/registrazione">Registrati</a> 
        </p>
    </form>
</div>


  • 确保文件中有来自flask导入请求的行

  • 确保您没有重新定义
    请求
    。或者您已经明确定义了另一个名为
    request

     def request():
         ...
    
    或者您已将功能分配给
    请求

      request = some_random_method
    

  • 你的缩进消失了。除此之外,您是否在全局范围内定义了名为
    request
    的内容?缩进只是一个复制粘贴错误,在代码正确的情况下,request是从烧瓶库导入的。我在文件底部有一个func request,谢谢,我没有注意到这一点