Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Python flask render_template not working

You need to post the stack trace from the console. "Not working" is too vague, and the response page isn't going to be very useful either, as it's not going to provide a lot of detail by design.

here is from the error log (not sure if its what you wanted):

2015-03-29 17:18:27,289 : for f in self.filters: 2015-03-29 17:18:27,289 : File "/bin/user_wsgi_wrapper.py", line 122, in call 2015-03-29 17:18:27,289 : app_iterator = self.app(environ, start_response) 2015-03-29 17:18:27,289 : File "/bin/user_wsgi_wrapper.py", line 136, in import_error_application 2015-03-29 17:18:27,289 : raise e 2015-03-29 17:18:27,289 : File "/bin/user_wsgi_wrapper.py", line 130, in call 2015-03-29 17:18:27,289 : self.error_log_file.logger.exception("Error running WSGI application") 2015-03-29 17:18:27,289 : File "/usr/lib/python3.4/logging/init.py", line 1296, in exception 2015-03-29 17:18:27,290 : self.error(msg, *args, **kwargs) 2015-03-29 17:18:27,290 : File "/usr/lib/python3.4/logging/init.py", line 1289, in error 2015-03-29 17:18:27,291 : self.log(ERROR, msg, args, **kwargs) 2015-03-29 17:18:27,291 : File "/usr/lib/python3.4/logging/init.py", line 1395, in _log 2015-03-29 17:18:27,291 : self.handle(record) 2015-03-29 17:18:27,291 : File "/usr/lib/python3.4/logging/init.py", line 1404, in handle 2015-03-29 17:18:27,292 : if (not self.disabled) and self.filter(record): 2015-03-29 17:18:27,292 : File "/usr/lib/python3.4/logging/init.py", line 692, in filter 2015-03-29 17:18:27,292 : for f in self.filters: 2015-03-29 17:18:27,292 : File "/bin/user_wsgi_wrapper.py", line 122, in __call_ 2015-03-29 17:18:27,293 : app_iterator = self.app(environ, start_response) 2015-03-29 17:18:27,293 : File "/bin/user_wsgi_wrapper.py", line 136, in import_error_application 2015-03-29 17:18:27,293 : raise e 2015-03-29 17:18:27,293 : File "/bin/user_wsgi_wrapper.py", line 145, in <module> 2015-03-29 17:18:27,293 : application = load_wsgi_application() 2015-03-29 17:18:27,293 : File "/bin/user_wsgi_wrapper.py", line 141, in load_wsgi_application 2015-03-29 17:18:27,293 : return import(os.environ['WSGI_MODULE'], globals(), locals(), ['application']).application 2015-03-29 17:18:27,293 : File "/var/www/davidf_pythonanywhere_com_wsgi.py", line 16, in <module> 2015-03-29 17:18:27,294 : from flask_app import app as application 2015-03-29 17:18:27,294 : File "/home/davidf/mysite/flask_app.py", line 9 2015-03-29 17:18:27,294 : @app.route('/welcome' method = 'post') 2015-03-29 17:18:27,294 : ^ 2015-03-29 17:18:27,294 :SyntaxError: invalid syntax

1 Answer

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Well, like the stack trace says, you have invalid syntax. You can't use method='post' when defining a view. methods is plural and has to be a list or tuple. You want methods=['POST'].