title: How to get form data in Flask?
body: <p>I need get data from form.</p>
  
  <p>I use JavaScript to create form:</p>
  
  <pre><code>&lt;script&gt;   
  function checkAuth() {
                  var user = ADAL.getCachedUser();
                  if (user) {
                      var form = $('&lt;form style="position: absolute; width: 0; height: 0; opacity: 0; display: none; visibility: hidden;" method="POST" action= "{{ url_for("general.microsoft") }}"&gt;');
  
                      form.append('&lt;input type="hidden" name="token" value="' + ADAL.getCachedToken(ADAL.config.clientId) + '"&gt;');
                      form.append('&lt;input type="hidden" name="json" value="' + encodeURIComponent(JSON.stringify(user)) + '"&gt;');
                      $("body").append(form);
                      form.submit();
                  }
              }
  &lt;/script&gt; 
  </code></pre>
  
  <p>then I need to get data from the input field which <code>name="json"</code>.</p>
  
  <p>Here is my view function: </p>
  
  <pre><code>@general.route("/microsoft/", methods=["GET", "POST"])
  @csrf.exempt
  def microsoft():
      form = cgi.FieldStorage()
      name = form['json'].value
      return name
  </code></pre>
  
  <p>But I get an error:</p>
  
  <p><code>builtins.KeyError KeyError: 'json'</code></p>
  
  <p>Help me get data from form.</p>