-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServerFinder.py
More file actions
50 lines (42 loc) · 1.47 KB
/
Copy pathServerFinder.py
File metadata and controls
50 lines (42 loc) · 1.47 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import cherrypy
from CollectionModule.mongo_db_handler import collection_manager
class QueryFinder(object):
@cherrypy.expose
def index(self):
return '''<html>
<head></head>
<body>
<form method="get" action="run_matcher">
<input type="text" value="" name="name" />
<button type="submit">Submit</button>
</form>
</body>
</html>'''
@cherrypy.expose
@cherrypy.tools.json_out()
def run_matcher(self, name):
client = collection_manager("testDatabase", "users")
query = {"name" : name}
l_one = client.find_query(query)
if not l_one:
return "No Query Results"
else:
id_bank = l_one[0]
id_number = id_bank["_id"]
client.change_collection("transactions")
returner = client.find_query({"user_id": str(id_number) })
print(returner)
if not returner:
return "No Transaction Results"
for dict in returner:
for key in dict:
if key == "_id":
temp = str(dict[key])
n_temp = temp.replace("ObjectId", "")
nn_temp = n_temp.replace(")", "")
dict[key] = nn_temp
print(returner)
return returner
if __name__ == '__main__':
cherrypy.quickstart(QueryFinder())
QueryFinder().run_matcher("Aaron")