I am new to python and the google app engine. I am trying to create this 
app that fetches feed from yahoo pipes and displays it using jinja2 
templates. However I am getting a syntax error and I am not understanding 
the reason behind it.

import webapp2
from webapp2_extras import jinja2
import logging


import feedparser  
import urllib


class BaseHandler(webapp2.RequestHandler):
    @webapp2.cached_property
    def jinja2(self):
        return jinja2.get_jinja2(app=self.app)
        
    def render_response(self, _template, **context):
        rv = self.jinja2.render_template(_template, **context)
        self.response.write(rv)


class MainHandler(BaseHandler):
    def get(self):
        feed = feedparser.parse(
"http://pipes.yahoo.com/pipes/pipe.run?_id=1nWYbWm82xGjQylL00qv4w&_render=rss&textinput1=dogs";
 
)
        
        feed = [{"link": item.link, "title":item.title, "description" : item
.description} for item in feed["items"]
        context = {"feed" : feed, "search" : "dogs"}
        self.render_response('index.html', **context)
        
        def post(self):


            terms = self.request.get('search_term')


            terms = urllib.quote(terms)
            feed = feedparser.parse(
"http://pipes.yahoo.com/pipes/pipe.run?_id=1nWYbWm82xGjQylL00qv4w&_render=rss&textinput1=";
 
+ terms )
            
            feed = [{"link": item.link, "title":item.title, "description" :item
.description} for item in feed["items"]]


            context = {"feed": feed, "search": terms}


            self.render_response('index.html', **context)


app = webapp2.WSGIApplication([
    ('/', MainHandler)
], debug=True)


Here is the index.html file

<!DOCTYPE html>
<html>
<head>
<title>Byte 1 Tutoral</title>
</head>
<body>
<h1>Data Pipeline Project Byte 1 Example</h1>
<form action="search" method="POST">
  Search Term: <input name="search_term" value={{search}}><br>
  <input type="submit" value="Enter Search Term">
</form>
{% if search: %}
<p>Searching for {{search}}</p>
{% endif %}


<h2>Feed Contents</h2>
{% for item in feed %}
<a href="{{ item.link }}">{{ item.title }}</a><br>
{{item.description|safe}}
<br>
{% endfor %}


</body>
</html>
 
and this is the error that I am getting.

Thanks. 

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to