title: How to utilize bootstrap toggle with flask
body: <p>This question is an extension of <a href="https://stackoverflow.com/questions/37267748/how-to-utilize-bootstrap-ti-ta-toggle-checkbox-with-flask">this</a> question regarding using the Bootstrap toggle with flask.</p>
  
  <p>My code for the toggle is as follows:</p>
  
  <pre><code>&lt;div class='media'&gt;
                  &lt;div class='media-left'&gt;
                    &lt;div class='media-object'&gt;
                      &lt;div class='padding-right'&gt;
                        &lt;form action="/menu" method="post"&gt;
                          &lt;input name="toggle" onclick="this.form.submit()" data-off="&amp;lt;i class='fa fa-times'&amp;gt;&amp;lt;/i&amp;gt; " data-on="&amp;lt;i class='fa fa-check'&amp;gt;&amp;lt;/i&amp;gt; " data-onstyle='success' data-size='large' data-style='ios' data-toggle='toggle' id='activate-toggle' type='checkbox' value="on"&gt;
                          &lt;input name="toggle" type="hidden" value="off"&gt;
                        &lt;/form&gt;
                      &lt;/div&gt;
                    &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class='media-body'&gt;
                    &lt;div id='console-event'&gt;&lt;/div&gt;
                  &lt;/div&gt;
                &lt;/div&gt;
  </code></pre>
  
  <p>And my endpoint for the page is as follows:</p>
  
  <pre><code>    @app.route('/menu', methods=['POST', 'GET'])
  def get_callback():
      if request.method == 'POST':
          button = request.form['toggle']
          print(button)
      return render_template('dashboard.html')
  </code></pre>
  
  <p>However I am not able to get any response from my button.</p>
  
  <p>I am very lost at this point. I have tried to copy the format of the question above however I still cannot get the button to print or even use the POST method.</p>
  
  <p>Here are my questions:</p>
  
  <ol>
  <li>How can I get a response from my button?</li>
  <li>How do I save the orientation so that when the user logs back in the button is how they previously left it?</li>
  </ol>
  
  <p>(I am using SQLAlchemy if this is of any importance.)</p>
  
  <p>Any help would be greatly appreciated!</p>
  
  <p>Thank you,</p>
  
  <p>Jonah</p>