forked from KasenJ/CommunityPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstartFollowHandler.py
More file actions
25 lines (23 loc) · 908 Bytes
/
startFollowHandler.py
File metadata and controls
25 lines (23 loc) · 908 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
import tornado.ioloop
import tornado.web
import tornado.httpserver
import json
class startFollowHandler(tornado.web.RequestHandler):
def get(self):
self.write("<p>startFollowHandler</p><form action='/api/startfollow' method='post'><input type='submit' value='submit'></form>")
def post(self):
content='{"eid":2,"name":"ooo"}'
j=json.loads(content)
user=self.application.dbapi.getUserByUserName(j['name'])["id"]
if(user):
if(self.application.dbapi.getFollow(user["id"],j['eid'])):
data=[{'state':3},{'desc':"have been followed"}]#have been followed
result=json.dumps(data)
else:
self.application.dbapi.insertFollow(user["id"],j['eid'])
data=[{'state':1},{'desc':"start follow success"}]#start follow success
result=json.dumps(data)
else:
data=[{'state':2},{'desc':"user no exist"}]#user no exist
result=json.dumps(data)
#return result