修正 snooze 命令无效的问题 (after ba7f88a)
[gaetalk.git] / clean.py
blob3537e3308466bab293ecd85d419becb473f034fa
1 #!/usr/bin/env python2
2 # vim:fileencoding=utf-8
4 import lilytalk
5 import logging
6 from google.appengine.ext import webapp
7 from google.appengine.ext.webapp.util import run_wsgi_app
9 class CleanLog(webapp.RequestHandler):
10 def get(self):
11 self.response.headers['Content-Type'] = 'text/html; charset=UTF-8';
12 self.response.out.write(u'''<!DOCTYPE html>
13 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
14 <title>清除所有日志</title>
15 <form method="post">
16 <input type="submit" value="确认清除所有日志"/>
17 </form>'''.encode('utf-8'))
19 def post(self):
20 logging.warn('清除所有日志')
21 for l in lilytalk.Log.all():
22 l.delete()
23 self.response.out.write(u'已删除所有日志'.encode('utf-8'))
25 class CleanUser(webapp.RequestHandler):
26 def get(self):
27 self.response.headers['Content-Type'] = 'text/html; charset=UTF-8';
28 self.response.out.write(u'''<!DOCTYPE html>
29 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
30 <title>清除所有用户信息</title>
31 <form method="post">
32 <input type="submit" value="确认清除所有用户信息"/>
33 </form>'''.encode('utf-8'))
35 def post(self):
36 logging.warn('清除所有用户信息')
37 for l in lilytalk.User.all():
38 l.delete()
39 self.response.out.write(u'已删除所有用户信息'.encode('utf-8'))
41 application = webapp.WSGIApplication(
43 ('/_admin/cleanuser', CleanUser),
44 ('/_admin/cleanlog', CleanLog),
46 debug=True)
48 def main():
49 run_wsgi_app(application)
51 if __name__ == "__main__":
52 main()