File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -96,6 +96,21 @@ def addSub(userID, categoryNames):
96
96
print ("New subscription" )
97
97
return "user subscribed"
98
98
99
+ def addSubAll (userID ):
100
+ userID = str (userID )
101
+ conn = sqlite3 .connect ('posts.db' )
102
+ c = conn .cursor ()
103
+ with conn :
104
+ c .execute ("SELECT topic FROM topics" )
105
+ x = c .fetchall ()
106
+ topicList = ""
107
+ for topic in x :
108
+ topicList += topic [0 ]
109
+ topicList += ","
110
+ # print(topicList)
111
+ addSub (userID ,topicList )
112
+ return "user subscribed to all"
113
+
99
114
def unSub (userID , categoryNames ):
100
115
conn = sqlite3 .connect ('posts.db' )
101
116
c = conn .cursor ()
@@ -114,3 +129,4 @@ def unSub(userID, categoryNames):
114
129
print ("Unsubscibed " + str (userID )+ " from " + category )
115
130
return "user unsubscribed"
116
131
132
+
Original file line number Diff line number Diff line change @@ -86,6 +86,11 @@ def postJson():
86
86
db .injectData (ReadCSV (filename ))
87
87
return Response ('We received something...' )
88
88
89
+ @app .route ("/addUserSubscriptionAll" , methods = ['POST' ])
90
+ def addSubAll ():
91
+ data = json .loads (request .data .decode ("utf-8" ))
92
+ return db .addSubAll (data ["userid" ])
93
+
89
94
if __name__ == "__main__" :
90
95
DBsetup ()
91
96
app .run ()#host=HOSTADDRESS, port=80)
You can’t perform that action at this time.
0 commit comments