title: ValueError: View function did not return a response in flask
body: <p>So there are several of this questions already asked and the error for this means that the function has to return a value, or simply means it should return something.</p>
  
  <p>I already have it in my routes.py file but its still not working.</p>
  
  <p>Here is the code for route.py</p>
  
  <pre><code>from flask import *
  from functools import wraps
  app = Flask(__name__)
  app.secret_key = "my precious"
  
  @app.route('/')
  def home():
       return render_template('home.html')
  
  @app.route('/welcome')
  def welcome():
      return render_template('welcome.html')
  
  @app.route('/logout')   
  def logout():
      session.pop('logged_in',None)
      return redirect (url_for('home'))
  
  @app.route('/hello')
  def hello():
      return render_template('hello.html')
  
  
  @app.route('/log', methods=['GET','POST'])
  def log():
      error = None
      if request.method == "POST":
          if request.form['username'] != 'admin' or  request.form['password'] != 'admin':
              error = "Invalid credentials"
          else: 
              session['logged_in'] = True
              return redirect (url_for('hello'))
          return render_template('log.html', error=error)
  
  
  if __name__ == '__main__':
     app.run(debug=True)
  </code></pre>
  
  <p>Code for log.html</p>
  
  <pre><code>{% extends "templates.html" %}
  {% block content %}
      &lt;h1&gt;Login&lt;/h1&gt;
      {% If error %}
          &lt;p class=error&gt; &lt;strong&gt; Error: &lt;/strong&gt; {{ error }}
      {% endif %}
      &lt;form action="" method="POST"&gt;
          &lt;dl&gt;
              &lt;dt&gt;Username:
              &lt;dt&gt;&lt;input type="text" name="username" value="{{
              request.form.username }}"&gt;
              &lt;dt&gt;Password:
              &lt;dd&gt;&lt;input type="password" name="passowrd"&gt; 
          &lt;/dl&gt;
          &lt;p&gt;&lt;input type="submit" value="Login"&gt;      
      &lt;/form&gt;
  {% endblock %}
  </code></pre>
  
  <p>code for templates.html</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
          &lt;title&gt;Flask tutorial (Part 1)&lt;/title&gt;
  &lt;/head&gt;
      &lt;header&gt;
      &lt;div class="navbar navbar-inverse"&gt;
      &lt;div class="navbar-inner"&gt;  
          &lt;a class="brand" href="/"&gt;Real python (for the web!)&lt;/a&gt;
          &lt;ul&gt;
              &lt;li&gt;&lt;a href="/welcome"&gt;Welcome&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href="/log"&gt;login&lt;/a&gt;&lt;/li&gt;
          &lt;/ul&gt;
      &lt;/div&gt;
      &lt;/div&gt;
      &lt;/header&gt;
  &lt;body&gt;
      &lt;div class="container"&gt;
          {% block content %}
          {% endblock %}
      &lt;/div&gt;  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>code for home.html</p>
  
  <pre><code>{% extends "templates.html"%}
  {% block content %}
      &lt;div class="jumbo"&gt;
          &lt;h2&gt;Welcome to Flask&lt;/h2&gt;
          &lt;br/&gt;
          &lt;p&gt;click &lt;a href="/welcome"&gt;here&lt;/a&gt; to go to welcome page&lt;/p&gt;
      &lt;/div&gt;  
  {% endblock %}  
  </code></pre>
  
  <p>code for hello.html </p>
  
  <pre><code>{% extends "templates.html" %}
  {% block content %}
      &lt;h2&gt;Welcome! You are logged in.&lt;/h2&gt;
  {% endblock %}
  </code></pre>
  
  <p>code for welcome.html</p>
  
  <pre><code>{% extends "templates.html"%}
  {% block content %}
      &lt;h2&gt;Sample&lt;/h2&gt;
      &lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;/p&gt;
      &lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;/p&gt;
  {% endblock %}  
  </code></pre>
  
  <p>Can someone help me where I am going wrong?
  Thanks in advance</p>