title: Flask loop through POST Requests with input data
body: <p>So I have created code that fetches json data from a schedule and prints the key value pairs with for loops on a flask template. The values from the pairs are in a text field and you should be able to update the values when submitting. The problem is I do not get how to be able to loop through every lecture from the schedule, I just manage to do it to the first one.</p>
  
  <p>Here is my form</p>
  
  <pre><code>&lt;form method="POST"&gt;
      &lt;body&gt;
      &lt;h1&gt;Uppdatera lektion&lt;/h1&gt;
          {%for dict_item in update%}
          &lt;br&gt;
              {%for key, value in dict_item.items()%}
                  &lt;br&gt;
                      &lt;b&gt;{{key}}&lt;/b&gt;
                      &lt;input type="text" name="values" value="{{value}}"/&gt;
                  &lt;/br&gt;
              {%endfor%}
          &lt;/br&gt;
          {%endfor%}
      &lt;input type=submit value=Registrera&gt;
      &lt;/body&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Here is my post method</p>
  
  <pre><code>if request.method == "POST":
      input_values = request.form.getlist("values")
  
      url = "https://ltu.instructure.com/api/v1/calendar_events.json"
  
      payload = {
          'calendar_event[context_code]': "MY_USER",
          'calendar_event[title]': input_values[0],
          'calendar_event[start_at]': input_values[1]+"T"+input_values[2]+"Z",
          'calendar_event[end_at]': input_values[3]+"T"+input_values[4]+"Z",
          'calendar_event[description]': input_values[5]
          }
  
      headers = {
          'Authorization': "MY_TOKEN",
          'cache-control': "no-cache",
          'Postman-Token': "e0bc1a1c-5baf-47f8-a2ce-62d476040e73"
          }
  
      r = requests.post(url, data=payload, headers=headers)
  
      print(r.text)
  return "Uppdateringen lyckades!"
  </code></pre>
  
  <p>Here is how the lecture format with keys and values looks like on the browser</p>
  
  <p><a href="https://imgur.com/YDIMslw" rel="nofollow noreferrer">https://imgur.com/YDIMslw</a></p>
  
  <p>So yeah, I need some advice here on how to move on and be able to update all the lectures not just the first one. Thanks in advance!</p>