title: flask Indentation errors for returns
body: <p>I keep having indentation issues with my flask app.<br>
  Specifically when I try to declare a variable before a return statement.  Also when I try to use <code>session['logged_in] = True</code> before a return statement.</p>
  
  <p>Tried searching for any indication that i am structuring this incorrectly, what am I missing?</p>
  
  <pre><code>from app import app
  from flask import render_template, url_for, request, url_for, redirect, session
  from form import NewUser
  
  @app.route('/')
  def home():
      return render_template('home.html')
  
  @app.route('/logout')
  def logout():
      session.pop('logged_in', None)
      redirect(url_for('home'))
  
  @app.route('/login', methods=['POST', 'GET'])
  def login():
      form = NewUser()
  
      if request.method == 'POST':
          if request.form['username'] != 'admin' and request.form['password'] != 'password':
              error = "uername/password incorrect"
              return render_template('login.html', form=form, error=error)
          else:
              session['logged_in'] = True
              return redirect(url_for('secretarea'))
      return render_template('login.html', form=form, error=error)
  
  
  @app.route('/secretarea')
  def secretarea():
      if session['logged_in'] = True:
          return "this area is a secret"
      else:
          error="please log in"
          return render_template('login.html', error=error)
  </code></pre>
  
  <p>The error I get is this</p>
  
  <pre><code>  File "runserver.py", line 2, in &lt;module&gt;
      from app import app
    File "/home/roman/flask/myblog/app/__init__.py", line 9, in &lt;module&gt;
      from app import views
    File "/home/roman/flask/myblog/app/views.py", line 21
      return render_template('login.html', form=form, error=error)
      ^
    IndentationError: unexpected indent
  </code></pre>