Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flask render_template() returning "NameError: name 'app' is not defined"

Tags:

python

flask

I am following the Quickstart Guide for Flask. http://flask.pocoo.org/docs/quickstart/#static-files I'm getting this error as I follow the guide.

/application
/__init__.py
/templates
    /hello.html

   @app.route('/hello/')
   @app.route('/hello/<name>')
   def hello(name=None):
       return render_template('hello.html', name=name)

    >python _init_.py 
        Traceback (most recent call last):
        File "_init_.py", line 4, in <module>
   @app.route('/hello/')
   NameError: name 'app' is not defined
like image 510
ronyswag Avatar asked May 30 '12 04:05

ronyswag


2 Answers

Perhaps this?

from flask import Flask, request, render_template
like image 94
david garvey Avatar answered Oct 04 '22 15:10

david garvey


The only thing missing is

from flask import Flask, render_template
like image 21
keith Avatar answered Oct 04 '22 17:10

keith