title: Flask Error, in Python script does not work
body: <p>unfortunately my script no longer works in Flask. I don't know how to fix this. I would be very grateful if you could help me. Here are my codes:</p>
  <pre class="lang-py prettyprint-override"><code>@app.route(&quot;/register&quot;, methods=[&quot;GET&quot;, &quot;POST&quot;])
  def register():
      if request.method == &quot;POST&quot;:
          username = request.form[&quot;uname&quot;]
          password = request.form[&quot;passwd&quot;]
          with open(&quot;user.txt&quot;, &quot;r&quot;) as file:
              file.write(username + &quot;\n&quot; + password)
  
      return render_template(&quot;register.html&quot;)
  </code></pre>
  <pre class="lang-html prettyprint-override"><code>&lt;form action=&quot;/register&quot; method=&quot;POST&quot;&gt;
      &lt;div class=&quot;container&quot;&gt;
          &lt;label for=&quot;usm&quot;&gt;&lt;b&gt;Username&lt;/b&gt;&lt;/label&gt;
          &lt;input type=&quot;text&quot; placeholder=&quot;Enter Username&quot; name=&quot;usm&quot; required&gt;
        
          &lt;label for=&quot;pwd&quot;&gt;&lt;b&gt;Password&lt;/b&gt;&lt;/label&gt;
          &lt;input type=&quot;password&quot; placeholder=&quot;Enter Password&quot; name=&quot;pwd&quot; required&gt;
        
          &lt;button type=&quot;submit&quot; name=&quot;login&quot;&gt;Login&lt;/button&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  <p>This is my error:</p>
  <pre><code>werkzeug.exceptions.BadRequestKeyError
  werkzeug.exceptions.BadRequestKeyError: 400 Bad Request: The browser (or proxy) sent a request that this server could not understand.
  KeyError: 'uname'
  </code></pre>