title: Python Counter add and subtract
body: <p>I got the counter working  I am pretty sure I got the post get working. Could someone look at my code and tell me where it went wrong. The code keeps count of Sessions. I want the ninja button to +2 and the hacker to reset to 1.  Got all of it but the last two parts. Any help would be appreciated. </p>
  
  <pre><code>from flask import Flask, session, render_template, url_for, request, redirect
  app = Flask(__name__)
  app.secret_key = 'F12Zr47j\3yX R~X@H!jmM]Lwf/,?KT'
  
  
  def sumSessionCounter():
    try:
      session['counter'] += 1
    except KeyError:
      session['counter'] = 1
  
  
  @app.route('/')
  def index():
      sumSessionCounter()
      return render_template('index.html')
  
  
  def contact():
      if request.method == 'POST':
          if request.form['ninja'] == session['counter'] + 2:
              pass # do something
          elif request.form['hacker'] == session['counter'] - session['counter'] + 1 :
              pass # do something else
  
              pass # unknown
      elif request.method == 'GET':
          return render_template('contact.html', form=form)
  
  
  
  
  
  app.run(debug=True)
  </code></pre>
  
  <pre class="lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;&lt;/title&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;link rel="stylesheet" type="text/css" href="stylenew.css"&gt;&lt;/style&gt;
    &lt;script type="text/javascript" src='http://code.jquery.com/jquery-1.10.2.min.js'&gt;&lt;/script&gt; 
    &lt;script&gt;
  
  
    &lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h1&gt;{{session['counter']}}&lt;/h1&gt;
  
  &lt;p&gt;&lt;input type="submit" name="submit" value="ninja"&gt;&lt;/p&gt;
  &lt;p&gt;&lt;input type="submit" name="submit" value="hacker"&gt;&lt;/p&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>