-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnux.py
131 lines (106 loc) · 4.03 KB
/
nux.py
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import os
import subprocess
import uuid
import json
import time
from flask import Flask, request, render_template, url_for, redirect
from flask_table import Table, Col
import numpy as np
import azure.cosmos.cosmos_client as cosmos_client
from shutil import copyfile
import shutil
app = Flask(__name__)
app.secret_key = "secret key"
app.config['UPLOAD_FOLDER'] = 'C:/Users/funpa/OneDrive/Desktop/nux'
#config = {
# 'ENDPOINT': 'https://9928c7b3-0ee0-4-231-b9ee.documents.azure.com:443/',
# 'PRIMARYKEY': 'Z1Cu587FxkqD9T5yCIVPQQATZ2BmVEJ3GLsKs6SvqhAW9F5W9GgLba8mJXhMIlg4AF3obFaSOFybjlqxYDk3Nw==',
# 'DATABASE': 'CosmosDatabase',
# 'CONTAINER': 'CosmosContainer'
#}
#client = cosmos_client.CosmosClient(url_connection=config['ENDPOINT'], auth={'masterKey': config['PRIMARYKEY']})
#database_link = 'dbs/CosmosDatabase'
#database = client.ReadDatabase(database_link)
#id = 'CosmosContainer'
#collection_link = database_link + '/colls/{0}'.format(id)
#userContainer = client.ReadContainer(collection_link)
@app.route("/")
def fileFrontPage():
return render_template('homepage.html')
@app.route("/retrievePass", methods=["POST"])
def retrievePass():
userName = request.form['getpassfromUser']
find_entity_by_id_query = {
"query": "SELECT * FROM CosmosContainer c where c.id = @id",
"parameters": [
{ "name":"@id", "value": str(userName) }
]
}
options = {}
options['enableCrossPartitionQuery'] = True
entities = None
entities = list(client.QueryItems(collection_link, find_entity_by_id_query, options))
tempDict = entities[0]
print(tempDict['Password'])
return redirect(url_for('fileFrontPage'))
@app.route("/upload", methods=["GET", "POST"])
def fileUploadPage():
return render_template('features.html')
@app.route("/handleID", methods=["GET", "POST"])
def storeUser():
userID = request.form['userID']
password = request.form['password']
client.CreateItem(userContainer['_self'], {
'id': userID,
'Total Runs': 0,
'Password': password,
'FolderID': str(uuid.uuiud4())
}
)
return redirect(url_for('fileFrontPage'))
@app.route("/arrayDisplay", methods=["GET", "POST"])
def displayArrayInfo():
return render_template('displayData.html')
@app.route("/handleUpload", methods=['POST'])
def handleFileUpload():
threshold = 9
if 'photo' in request.files:
photo = request.files['photo']
if photo.filename != '':
uniqID = uuid.uuid4()
os.mkdir(str(uniqID))
os.mkdir(os.path.join(str(uniqID), 'labeled'))
shutil.copy('BranchLogger.class', os.path.join(str(uniqID), 'labeled'))
photo.save(os.path.join('C:/Users/funpa/OneDrive/Desktop/nux', str(uniqID), photo.filename))
subprocess.Popen(['initate.bat', str(uniqID), photo.filename, os.path.join(str(uniqID), 'labeled', 'BranchLogger.class')], shell=True)
filePresent = True
arrayData = []
while filePresent:
try:
with open(os.path.join(str(uniqID), str(threshold) + '_tendydemei.json')) as thefile:
arrayData = json.load(thefile)
filePresent = False
except:
continue
filePresent = True
temp = []
randomints = []
bitmaps = []
for bitvals in arrayData.values(): temp.append(bitvals)
i = 0
for rows in temp:
randomints.append(temp[i][0])
bitmaps.append(temp[i][1])
i += 1
q = 0
for val in bitmaps:
bitmaps[q] = np.sum(val)
q+=1
fullVals = [0] * len(bitmaps)
z = 0
for array in randomints:
fullVals[z] = np.append(array, bitmaps[z])
z += 1
return render_template('displayData.html', arrayInts = fullVals)
if __name__ == '__main__':
app.run(debug=True)