-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHandler.py
More file actions
51 lines (44 loc) · 1.33 KB
/
Handler.py
File metadata and controls
51 lines (44 loc) · 1.33 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
51
import pymongo
import gauss
schema = {
str,
str
}
uri = 'mongodb://admin:image112@host/image_processing'
print('Connecting to Mongo client...')
client = pymongo.MongoClient(uri)
db = client.get_database('image_processing')
users = db['users']
print('Connected')
while True:
inp_select = int(input("1. Create a new account\n2. Login to an existing account\n"))
if inp_select == 1:
username = input("Enter a new username: ")
pwd = gauss.grep('')
if users.find_one({'uname': username}):
print("A user with that name already exists........\n")
else:
print('Creating a new user')
username = username.lower()
ins = users.insert_one({
'uname': username,
'pwd': pwd
})
if ins.acknowledged:
print("New user added :) \n")
else:
print("An error occurred \n\n\n")
elif inp_select == 2:
username = input("Enter username: ")
username = username.lower()
pwd = gauss.grep('')
if users.find_one({
'uname': username,
'pwd': pwd
}):
print("Welcome " + username + '\n\n\n')
else:
print("A user with that credentials was not found......\n")
else:
break
client.close()