-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
30 lines (23 loc) · 879 Bytes
/
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
from google.appengine.ext.webapp import template
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.api import users
import os
import datetime
import bot
class MainPage(webapp.RequestHandler):
def get(self):
user = users.get_current_user()
chat_user = bot.ChatUser.gql("WHERE jid = :1", user.email()).get()
if not chat_user:
self.response.out.write("access denied")
else:
chat_log = bot.MessageLog.all().order('-created_at').fetch(500)
template_values = { 'chat_log': chat_log }
path = os.path.join(os.path.dirname(__file__), 'templates/index.html')
self.response.out.write(template.render(path, template_values))
application = webapp.WSGIApplication([('/', MainPage)])
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()