-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuserAPI.py
More file actions
87 lines (80 loc) · 2.89 KB
/
userAPI.py
File metadata and controls
87 lines (80 loc) · 2.89 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
from pymongo import MongoClient
from flask import Flask,request,abort
from os import getenv
from dotenv import load_dotenv
load_dotenv()
connection = f"mongodb://mongoadmin:{getenv('mongoPass')}@localhost:27017"
client = MongoClient(connection)
app = Flask(__name__)
@app.route('/polygon')
def index():
try:
wallet = str(request.args.get("address"))
except:
return "'address' parameter was not specified",404
wallet = str(request.args.get("address"))
#client = MongoClient("mongodb://localhost:27017/")
database = client["mobile"]
wallets = database["wallets"]
users = database["users"]
try:
userDetails = users.find_one({"SCW Address":str(wallet)})
except:
return "wallet address was not found",404
userDetails = users.find_one({"SCW Address":str(wallet)})
if userDetails == None:
return "wallet address was not found",404
return userDetails["Username"],200
@app.route('/uuid')
def uuid():
try:
wallet = str(request.args.get("uuid"))
except:
return "'uuid' parameter was not specified",404
uuid = str(request.args.get("uuid"))
database = client["mobile"]
wallets = database["wallets"]
users = database["users"]
try:
usernameDetails = users.find_one({"ID":str(uuid)})
except:
return "username was not found",404
userDetails = users.find_one({"ID":uuid})
return userDetails["SCW Address"],200
@app.route('/email')
def email():
try:
address = str(request.args.get("address"))
except:
return "'address' parameter was not specified",404
address = str(request.args.get("address"))
database = client["mobile"]
users = database["users"]
try:
userDetails = users.find_one({"SCW Address":str(address)})
except:
return f"Wallet Address was not found",404
userDetails = users.find_one({"SCW Address":str(address)})
if userDetails == None:
return "Email Address was not found",404
email = userDetails["Email"]
return email,200
@app.route('/mercleAPI')
def mercle():
try:
address = str(request.args.get("address"))
except:
return "'address' parameter was not specified",404
address = str(request.args.get("address"))
database = client["mobile"]
users = database["users"]
try:
userDetails = users.find_one({"SCW Address":str(address)})
if userDetails == None:
return "false", 404
else:
return "true", 200
except:
return "false",404
if __name__ == '__main__':
app.run('127.0.0.1',8003)