forked from KasenJ/CommunityPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCancelHandler.py
More file actions
29 lines (28 loc) · 961 Bytes
/
CancelHandler.py
File metadata and controls
29 lines (28 loc) · 961 Bytes
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
import tornado.ioloop
import tornado.web
import tornado.httpserver
import json
class CancelHandler(tornado.web.RequestHandler):
def get(self):
self.write("<p>CancelHandler</p><form action='/api/cancel' method='post'><input type='submit' value='submit'></form>")
def post(self):
#content = self.get_argument("content")
content = '{"username":"test","password":"test"}'
j = json.loads(content)
if(j['username'].strip()=='' or j['password'].strip()==''):
self.write("{'state':1}")
print "username or password is null,can not cancel"
return
user = self.application.dbapi.getUserByUserName(j['username'])
if(user is None):
self.write("{'state':1}")
print "username not exist,can not cancel"
return
if(user["password"]!= j['password']):
self.write("{'state':2}")
print "passwd incorrect,can not cancel"
return
self.application.dbapi.cancelUser(user['id'])
self.write("{'state':3}")
print("cancel success")
return