forked from KasenJ/CommunityPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdateCid.py
More file actions
23 lines (21 loc) · 686 Bytes
/
UpdateCid.py
File metadata and controls
23 lines (21 loc) · 686 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# -*- coding: utf-8 -*-
import tornado.ioloop
import tornado.web
import tornado.httpserver
import json
class UpdateCid(tornado.web.RequestHandler):
def get(self):
self.write("<p>UpdateCid</p><form action='/api/updatecid' method='post'><input type='submit' value='submit'></form>")
def post(self):
#content =self.request.body
content = '{"username":"test1","cid":"dasdada"}'
j = json.loads(content)
user = self.application.dbapi.getUserByUserName(j['username'])
if(user is None):
self.write("{'state':2}")
print "username not exist"
return
self.application.dbapi.UpdateCidByuid(j['cid'],user['id'])
self.write("{'state':1}")
print("Login success")
return