错误请求浏览器(或代理)发送了此服务器无法理解Python的请求

时间:2015-03-28 14:24:38

标签: python html flask

我是python的新手,我收到了上面列出的错误

@app.route('/AddNewInfo', methods = ['GET', 'POST'])
def AddNewInfo():
    if request.method == 'POST':
        name = request.form['name']
        email = request.form['email']
        submit = request.form['submit']
        if submit:
            with open("info.txt", "w") as text_file:
                text_file.write((name, email))
        return render_template('show_info.html',name=name, email=email)
    else:
        return render_template('AddNewInfo.html')

HTML:

<html>
 <head>
   <title>Add new information</title>
 </head>
 <body>
 <h1>Enter New Info</h1>
        <form action="" method="post">
            Name: <input type="text" name="name"><br />
            Email: <input type="text" name="email"><br />
            <input type="submit" value="Submit">
        </form>
   </body>

</html>

如果request.method ==&#39; POST&#39;如果它只返回AddNewInfo

,它的工作方式

固定 有一个帖子请求而不是我的index.html

0 个答案:

没有答案