title: builtins.NameError NameError: name 'flask' is not defined
body: <p>I am facing this problem while running my flask.py app:</p>
  
  <p><strong>Traceback:</strong></p>
  
  <pre><code>File "/root/sitetoggle/lib/python3.4/site-packages/flask/app.py", line 1997, in __call__
      return self.wsgi_app(environ, start_response)
    File "/root/sitetoggle/lib/python3.4/site-packages/flask/app.py", line 1985, in wsgi_app
      response = self.handle_exception(e)
    File "/root/sitetoggle/lib/python3.4/site-packages/flask/app.py", line 1540, in handle_exception
      reraise(exc_type, exc_value, tb)
    File "/root/sitetoggle/lib/python3.4/site-packages/flask/_compat.py", line 33, in reraise
      raise value
    File "/root/sitetoggle/lib/python3.4/site-packages/flask/app.py", line 1982, in wsgi_app
      response = self.full_dispatch_request()
    File "/root/sitetoggle/lib/python3.4/site-packages/flask/app.py", line 1614, in full_dispatch_request
      rv = self.handle_user_exception(e)
    File "/root/sitetoggle/lib/python3.4/site-packages/flask/app.py", line 1517, in handle_user_exception
      reraise(exc_type, exc_value, tb)
    File "/root/sitetoggle/lib/python3.4/site-packages/flask/_compat.py", line 33, in reraise
      raise value
    File "/root/sitetoggle/lib/python3.4/site-packages/flask/app.py", line 1612, in full_dispatch_request
      rv = self.dispatch_request()
    File "/root/sitetoggle/lib/python3.4/site-packages/flask/app.py", line 1598, in dispatch_request
      return self.view_functions[rule.endpoint](**req.view_args)
    File "/root/sitetoggle/flaskr/flaskr.py", line 117, in index
      return flask.Response(inner(), mimetype='text/html')  # text/html is required for most browsers to show th$
  NameError: name 'flask' is not define
  </code></pre>
  
  <p>Here is my flask and template html</p>
  
  <p><strong>flask.py</strong></p>
  
  <pre><code>import os
  import subprocess
  import request
  
  from flask import (Flask, request, session, g, redirect, url_for, abort, render_template, flash)
  
  app = Flask(__name__) # create the application instance :)
  app.config.from_object(__name__) # load config from this file , flaskr.py
  
  @app.route('/siteOFF', methods=['GET', 'POST'])
  def siteoff():
     error = None
     subprocess.call(['/root/sitetoggle/flaskr/testOFF.sh'], shell=True)
     return render_template('layout.html', error=error)
  
  
  @app.route('/siteON', methods=['GET', 'POST'])
  def siteon():
      def inner():
          proc = subprocess.Popen(
              ['dmesg'],             #call something with a lot of output so we can see it
              shell=True,
              stdout=subprocess.PIPE
          )
  
          for line in iter(proc.stdout.readline,''):
              time.sleep(1)                           # Don't need this just shows the text streaming
              yield line.rstrip() + '&lt;br/&gt;\n'
  
      return flask.Response(inner(), mimetype='text/html')  # text/html is required for most browsers to show th$
  if __name__ == "__main__":
      app.run()
  </code></pre>
  
  <p><strong>index.html</strong></p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;title&gt;Flaskr&lt;/title&gt;
  &lt;link rel=stylesheet type=text/css href="{{ url_for('static', filename='style.css') }}"&gt;
  &lt;div class=page&gt;
  &lt;div&gt;
  &lt;h4&gt;Turn site OFF or ON &lt;/h4&gt;
  &lt;input type="button" name="lien1" value="Turn ON site"
   onclick="self.location.href='http://10.10.1.8:5000/siteON'" style="background-color:#3cb371"
  style="color:white; font-weight:bold"onclick&gt;
  
  &lt;input type="button" name="lien2" value="Turn OFF site"
   onclick="self.location.href='http://10.10.1.8:5000/siteOFF'" style="background-color:#1ab171"
  style="color:white; font-weight:bold"onclick&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I am using the flaskr app which I customized to call bash script within the flask page. Everything else is still working correctly except the two functions siteon() and siteoff() which I defined in my flask.py and trying to call them in the html page.</p>