File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 4
4
from readCSV import ReadCSV
5
5
from dbsetup import DBsetup
6
6
from getUserSubs import getUserSubs
7
+ from getUsers import getUsers
7
8
import databaseOperations as db
8
9
import sqlite3
9
10
import os
@@ -96,6 +97,10 @@ def unSubAll():
96
97
data = json .loads (request .data .decode ("utf-8" ))
97
98
return db .unSubAll (data ["userid" ])
98
99
100
+ @app .route ("/getUsers" , methods = ['POST' ,'GET' ])
101
+ def getListOfUsers ():
102
+ return getUsers ()
103
+
99
104
if __name__ == "__main__" :
100
105
DBsetup ()
101
106
app .run ()#host=HOSTADDRESS, port=80)
Original file line number Diff line number Diff line change
1
+ import csv
2
+ import requests , json
3
+ import sqlite3
4
+ import databaseOperations as db
5
+ from flask import jsonify
6
+
7
+
8
+ def getUsers ():
9
+ conn = sqlite3 .connect ('posts.db' )
10
+ c = conn .cursor ()
11
+ to_send = {"users" :[]}
12
+ with conn :
13
+ c .execute ("SELECT userID from users" )
14
+ users_selected = c .fetchall ()
15
+ for user in users_selected :
16
+ to_send ["users" ].append (user [0 ])
17
+
18
+ conn .commit ()
19
+ conn .close ()
20
+ return jsonify (to_send )
You can’t perform that action at this time.
0 commit comments