-
Notifications
You must be signed in to change notification settings - Fork 0
/
searchcontent.py
43 lines (36 loc) · 1.19 KB
/
searchcontent.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import webapp2
import jinja2
from google.appengine.api import users
from google.appengine.ext import ndb
from myuser import MyUser
import os
JINJA_ENVIRONMENT = jinja2.Environment(
loader=jinja2.FileSystemLoader(os.path.dirname(__file__)),
extensions=['jinja2.ext.autoescape'],
autoescape=True
)
class SearchContent(webapp2.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/html'
myuser = MyUser()
uname = myuser.query().fetch()
action = self.request.get('button')
contentlist = []
if action == 'Search':
content = self.request.get('value')
#content = content.split()
for x in uname:
for y in x.tweet:
if content in y:
contentlist.append(y)
template_values = {
'myuser' : myuser,
'uname' : uname,
'contentlist' : contentlist
}
template =JINJA_ENVIRONMENT.get_template('searchcontent.html')
self.response.write(template.render(template_values))
def post(self):
action = self.request.get('button')
if action == 'Back':
self.redirect('/')