Skip to content

Commit fa7f681

Browse files
author
Khaled
committed
addSubAll implemented
1 parent 4e1a9dc commit fa7f681

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

flask/databaseOperations.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,21 @@ def addSub(userID, categoryNames):
9696
print("New subscription")
9797
return "user subscribed"
9898

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+
99114
def unSub(userID, categoryNames):
100115
conn = sqlite3.connect('posts.db')
101116
c = conn.cursor()
@@ -114,3 +129,4 @@ def unSub(userID, categoryNames):
114129
print("Unsubscibed "+str(userID)+" from "+category)
115130
return "user unsubscribed"
116131

132+

flask/flaskapp.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ def postJson():
8686
db.injectData(ReadCSV(filename))
8787
return Response('We received something...')
8888

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+
8994
if __name__ == "__main__":
9095
DBsetup()
9196
app.run()#host=HOSTADDRESS, port=80)

0 commit comments

Comments
 (0)