-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
41 lines (28 loc) · 1.17 KB
/
main.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
import wsgiref.handlers
import os
from google.appengine.ext.webapp import template
from google.appengine.ext import webapp
import app
import category
import models
from google.appengine.ext import db
class MainHandler(webapp.RequestHandler):
def get(self):
govapps = db.GqlQuery('SELECT * FROM App WHERE gov = True AND status = :1 ORDER BY rating DESC LIMIT 10', "Approved")
nongovapps = db.GqlQuery('SELECT * FROM App WHERE gov = False AND status = :1 ORDER BY rating DESC LIMIT 10', "Approved")
#publicsafetyapps = db.GqlQuery('SELECT * FROM App WHERE category = :1 ORDER BY rating DESC', "Public Safety")
#publicsafetyapps.fetch(1)
template_values = {
'govapps':govapps,
'nongovapps':nongovapps,
}
path = os.path.join(os.path.dirname(__file__), 'main.html')
self.response.out.write(template.render(path, template_values))
def main():
application = webapp.WSGIApplication([('/', MainHandler),
('/category', category.Category),
('/app', app.App)],
debug=True)
wsgiref.handlers.CGIHandler().run(application)
if __name__ == '__main__':
main()