Best JavaScript code snippet using tracetest
app.py
Source:app.py
1import os2import zipfile3from flask import Flask, request, redirect, url_for, flash, render_template,send_file4from werkzeug.utils import secure_filename5from flask_ngrok import run_with_ngrok6import dl_trainer78UPLOAD_FOLDER = os.path.dirname(os.path.realpath(__file__))9ALLOWED_EXTENSIONS = set(['zip'])1011app = Flask(__name__)12run_with_ngrok(app)1314filename = ""15filename_model = "model.pkl"1617b = "processing"18def allowed_file(filename):19 return '.' in filename and \20 filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS2122@app.route('/download_files')23def download_all():24 # Zip file Initialization and you can change the compression type25 zipfolder = zipfile.ZipFile('models.zip','w', compression = zipfile.ZIP_STORED)26 # zip all the files which are inside in the folder27 for root,dirs, files in os.walk('models/'):28 for file in files:29 zipfolder.write('models/'+file)30 zipfolder.close()31 return send_file('models.zip',32 mimetype = 'zip',33 attachment_filename= 'models.zip',34 as_attachment = True)35 # Delete the zip file if not needed36 os.remove("models.zip")3738@app.route('/', methods=['GET', 'POST'])39def upload_file():40 if request.method == 'POST':41 # check if the post request has the file part42 if 'file' not in request.files:43 flash('No file part')44 return redirect(request.url)45 file = request.files['file']46 # if user does not select file, browser also47 # submit a empty part without filename48 if file.filename == '':49 flash('No selected file')50 return redirect(request.url)51 if file and allowed_file(file.filename):52 global filename53 filename = secure_filename(file.filename)54 print(filename)55 file.save(os.path.join(UPLOAD_FOLDER, filename))56 zip_ref = zipfile.ZipFile(os.path.join(UPLOAD_FOLDER, filename), 'r')57 zip_ref.extractall(UPLOAD_FOLDER)58 zip_ref.close()59 return redirect(url_for('index',filename=filename))60 return render_template('upload.html')6162@app.route('/index', methods=['GET', 'POST'])63def index():64 if request.method == 'POST':65 print(request.form.getlist('hello'))66 z = request.form.getlist('hello')67 if z[0] == '1':68 return redirect(url_for('svc'))69 if z[0] == '2':70 return redirect(url_for('knn'))71 if z[0] == '3':72 return redirect(url_for('logistic'))73 if z[0] == '4':74 return redirect(url_for('adaboost'))75 if z[0] == '5':76 return redirect(url_for('naive'))77 if z[0] == '6':78 return redirect(url_for('resnet18'))79 if z[0] == '7':80 return redirect(url_for('resnet34'))81 if z[0] == '8':82 return redirect(url_for('resnet50'))83 if z[0] == '9':84 return redirect(url_for('resnet101'))85 if z[0] == '10':86 return redirect(url_for('resnet152'))87 if z[0] == '11':88 return redirect(url_for('densenet121'))89 if z[0] == '12':90 return redirect(url_for('densenet169'))91 if z[0] == '13':92 return redirect(url_for('densenet201'))93 if z[0] == '14':94 return redirect(url_for('densenet161'))95 if z[0] == '15':96 return redirect(url_for('alexnet'))97 if z[0] == '16':98 return redirect(url_for('squeezenet1_0'))99 if z[0] == '17':100 return redirect(url_for('squeezenet1_1'))101 if z[0] == '18':102 return redirect(url_for('vgg11'))103 if z[0] == '19':104 return redirect(url_for('vgg11_bn'))105 if z[0] == '20':106 return redirect(url_for('vgg13'))107 if z[0] == '21':108 return redirect(url_for('vgg13_bn'))109 if z[0] == '22':110 return redirect(url_for('vgg16'))111 if z[0] == '23':112 return redirect(url_for('vgg16_bn'))113 if z[0] == '24':114 return redirect(url_for('vgg19'))115 if z[0] == '25':116 return redirect(url_for('vgg19_bn'))117 try:118 #global filename119 import os120 num_classes = len(os.listdir(os.path.splitext(filename)[0]))121 print("Number of classes : ",num_classes)122 except:123 num_classes = "error"124 return render_template('select_model.html',filename=filename,num_class=num_classes)125126@app.route('/returnmodel/')127def returnmodel():128 try:129 return send_file("model.pkl")130 except Exception as e:131 return str(e)132133@app.route('/svc_classifier', methods=['GET', 'POST'])134def svc():135 global filename136 if request.method == 'POST':137 print(request.form.getlist('kernal')[0])138 kernel = request.form.getlist('kernal')[0]139 print(request.form.getlist('gamma')[0])140 gamma = request.form.getlist('gamma')[0]141 print(request.form.getlist('decision_function_shape')[0])142 decision_function_shape = request.form.getlist('decision_function_shape')[0]143 print(request.form.getlist('max_iter')[0])144 try:145 max_iter = int(request.form.getlist('max_iter')[0])146 except:147 max_iter = -1148 print(request.form.getlist('random_state')[0])149 try:150 random_state = int(request.form.getlist('random_state')[0])151 except:152 random_state = None153 print(request.form.getlist('shape1')[0])154 shape11 = int(request.form.getlist('shape1')[0])155 print(request.form.getlist('shape2')[0])156 shape22 = int(request.form.getlist('shape2')[0])157 import trainer158 a,bz = trainer.svc_model(kernel1=kernel,gamma1=gamma,max_iter1=max_iter, decision_function_shape1=decision_function_shape,random_state1=random_state,shape1 = shape11,shape2=shape22,file=os.path.splitext(filename)[0])159 global filename2160 filename2 = a161 global b162 b = bz163 return redirect(url_for('svc'))164 return render_template('upload_svc.html',something=str(b))165166@app.route('/logistic_classifier', methods=['GET', 'POST'])167def logistic():168 if request.method == 'POST':169 print(request.form.getlist('criterion'))170 print(request.form.getlist('splitter'))171 print(request.form.getlist('max_depth'))172 print(request.form.getlist('random_state'))173 print(request.form.getlist('min_samples_split'))174 print(request.form.getlist('max_features'))175 print(request.form.getlist('shape1')[0])176 shape11 = int(request.form.getlist('shape1')[0])177 print(request.form.getlist('shape2')[0])178 shape22 = int(request.form.getlist('shape2')[0])179 try:180 max_depth = int(request.form.getlist('max_depth')[0])181 except:182 max_depth = None183 try:184 min_samples_split = int(request.form.getlist('min_samples_split')[0])185 except:186 min_samples_split = 2187 try:188 min_samples_leaf = int(request.form.getlist('min_samples_leaf')[0])189 except:190 min_samples_leaf = 2191 try:192 random_state = int(request.form.getlist('random_state')[0])193 except:194 random_state = None195 if request.form.getlist('max_features')[0] == "None":196 max_features = None197 else:198 max_features = request.form.getlist('max_features')[0]199 criterion = request.form.getlist('criterion')[0]200 splitter = request.form.getlist('splitter')[0]201 global filename202 import trainer203 a,bz = trainer.logistic(criterion1=criterion, splitter1=splitter, max_depth1=max_depth, min_samples_split1=min_samples_split,min_samples_leaf1 =min_samples_leaf ,max_features1=max_features,random_state1=random_state,shape1 = shape11,shape2= shape22,file=os.path.splitext(filename)[0])204 filename2 = a205 global b206 b = bz207 return redirect(url_for('logistic'))208 return render_template('upload_logistic.html',something=str(b))209210@app.route('/adaboost_classifier', methods=['GET', 'POST'])211def adaboost():212 global filename213 if request.method == 'POST':214 print(request.form.getlist('learning_rate'))215 print(request.form.getlist('random_state'))216 print(request.form.getlist('n_estimators'))217 try:218 learning_rate = float(request.form.getlist('learning_rate')[0])219 except:220 learning_rate = 0.1221 try:222 random_state = int(request.form.getlist('random_state')[0])223 except:224 random_state = None225 try:226 n_estimators = int(request.form.getlist('n_estimators')[0])227 except:228 n_estimators = 100229 print(request.form.getlist('shape1')[0])230 shape11 = int(request.form.getlist('shape1')[0])231 print(request.form.getlist('shape2')[0])232 shape22 = int(request.form.getlist('shape2')[0])233 import trainer234 global filename235 a,bz = trainer.adaboost(n_estimators1=n_estimators,random_state1=random_state,learning_rate1=learning_rate,shape1 = shape11,shape2= shape22,file=os.path.splitext(filename)[0])236 global filename2237 filename2 = a238 global b239 b = bz240 return redirect(url_for('adaboost'))241 return render_template('upload_adaboost.html',something=str(b))242243@app.route('/knn_classifier', methods=['GET', 'POST'])244def knn():245 global filename246 if request.method == 'POST':247 print(request.form.getlist('weights'))248 print(request.form.getlist('algorithm'))249 print(request.form.getlist('leaf_size'))250 print(request.form.getlist('n_neighbors'))251 weights = request.form.getlist('weights')[0]252 algorithm = request.form.getlist('algorithm')[0]253 try:254 leaf_size = int(request.form.getlist('leaf_size')[0])255 except:256 leaf_size = 30257 try:258 n_neighbors = int(request.form.getlist('n_neighbors')[0])259 except:260 n_neighbors = 5261 print(request.form.getlist('shape1')[0])262 shape11 = int(request.form.getlist('shape1')[0])263 print(request.form.getlist('shape2')[0])264 shape22 = int(request.form.getlist('shape2')[0])265 import trainer266 a,bz = trainer.knn(weights1 =weights,leaf_size1=leaf_size,n_neighbors1 = n_neighbors,algorithm1 = algorithm,shape1 = shape11,shape2= shape22,file=os.path.splitext(filename)[0])267 global filename2268 filename2 = a269 global b270 b = bz271 return redirect(url_for('knn'))272 return render_template('upload_knn.html',something=str(b))273274@app.route('/naive_classifier', methods=['GET', 'POST'])275def naive():276 if request.method == 'POST':277 print(request.form.getlist('shape1')[0])278 shape11 = int(request.form.getlist('shape1')[0])279 print(request.form.getlist('shape2')[0])280 shape22 = int(request.form.getlist('shape2')[0])281 import trainer282 a,bz = trainer.naivebayes(shape1 = shape11,shape2= shape22,file=os.path.splitext(filename)[0])283 global filename2284 filename2 = a285 global b286 b = bz287 return redirect(url_for('naive'))288 return render_template('upload_naive.html',something=str(b))289290291292@app.route('/resnet18_classifier', methods=['GET', 'POST'])293def resnet18():294 global filename295 if request.method == 'POST':296 print(request.form.getlist('augmentation')[0])297 try:298 augmentation = int(request.form.getlist('augmentation')[0])299 except:300 augmentation = 1301 try:302 epochs = int(request.form.getlist('epochs')[0])303 except:304 epochs = 4305 print(request.form.getlist('epochs')[0])306 print(request.form.getlist('validation_split')[0])307 validation_split = float(request.form.getlist('validation_split')[0])308 import dl_trainer309 file = os.path.splitext(filename)[0]310 a,bz = dl_trainer.dl_models(filename=file,model=1,aug=augmentation,epochs=epochs,validation_split=validation_split)311 global filename2312 filename2 = a313 global b314 b = bz315 return redirect(url_for('resnet18'))316 return render_template('upload_resnet18.html',something=str(b))317318@app.route('/resnet34_classifier', methods=['GET', 'POST'])319def resnet34():320 global filename321 if request.method == 'POST':322 print(request.form.getlist('augmentation')[0])323 try:324 augmentation = int(request.form.getlist('augmentation')[0])325 except:326 augmentation = 1327 try:328 epochs = int(request.form.getlist('epochs')[0])329 except:330 epochs = 4331 print(request.form.getlist('epochs')[0])332 print(request.form.getlist('validation_split')[0])333 validation_split = float(request.form.getlist('validation_split')[0])334 import dl_trainer335 file = os.path.splitext(filename)[0]336 a,bz = dl_trainer.dl_models(filename=file,model=2,aug=augmentation,epochs=epochs,validation_split=validation_split)337 global filename2338 filename2 = a339 global b340 b = bz341 return redirect(url_for('resnet34'))342 return render_template('upload_resnet34.html',something=str(b))343344@app.route('/resnet50_classifier', methods=['GET', 'POST'])345def resnet50():346 global filename347 if request.method == 'POST':348 print(request.form.getlist('augmentation')[0])349 try:350 augmentation = int(request.form.getlist('augmentation')[0])351 except:352 augmentation = 1353 try:354 epochs = int(request.form.getlist('epochs')[0])355 except:356 epochs = 4357 print(request.form.getlist('epochs')[0])358 print(request.form.getlist('validation_split')[0])359 validation_split = float(request.form.getlist('validation_split')[0])360 import dl_trainer361 file = os.path.splitext(filename)[0]362 a,bz = dl_trainer.dl_models(filename=file,model=3,aug=augmentation,epochs=epochs,validation_split=validation_split)363 global filename2364 filename2 = a365 global b366 b = bz367 return redirect(url_for('resnet50'))368 return render_template('upload_resnet50.html',something=str(b))369370@app.route('/resnet101_classifier', methods=['GET', 'POST'])371def resnet101():372 global filename373 if request.method == 'POST':374 print(request.form.getlist('augmentation')[0])375 try:376 augmentation = int(request.form.getlist('augmentation')[0])377 except:378 augmentation = 1379 try:380 epochs = int(request.form.getlist('epochs')[0])381 except:382 epochs = 4383 print(request.form.getlist('epochs')[0])384 print(request.form.getlist('validation_split')[0])385 validation_split = float(request.form.getlist('validation_split')[0])386 import dl_trainer387 file = os.path.splitext(filename)[0]388 a,bz = dl_trainer.dl_models(filename=file,model=4,aug=augmentation,epochs=epochs,validation_split=validation_split)389 global filename2390 filename2 = a391 global b392 b = bz393 return redirect(url_for('resnet101'))394 return render_template('upload_resnet101.html',something=str(b))395396@app.route('/resnet152_classifier', methods=['GET', 'POST'])397def resnet152():398 global filename399 if request.method == 'POST':400 print(request.form.getlist('augmentation')[0])401 try:402 augmentation = int(request.form.getlist('augmentation')[0])403 except:404 augmentation = 1405 try:406 epochs = int(request.form.getlist('epochs')[0])407 except:408 epochs = 4409 print(request.form.getlist('epochs')[0])410 print(request.form.getlist('validation_split')[0])411 validation_split = float(request.form.getlist('validation_split')[0])412 import dl_trainer413 file = os.path.splitext(filename)[0]414 a,bz = dl_trainer.dl_models(filename=file,model=5,aug=augmentation,epochs=epochs,validation_split=validation_split)415 global filename2416 filename2 = a417 global b418 b = bz419 return redirect(url_for('resnet152'))420 return render_template('upload_resnet152.html',something=str(b))421422@app.route('/densenet121_classifier', methods=['GET', 'POST'])423def densenet121():424 global filename425 if request.method == 'POST':426 print(request.form.getlist('augmentation')[0])427 try:428 augmentation = int(request.form.getlist('augmentation')[0])429 except:430 augmentation = 1431 try:432 epochs = int(request.form.getlist('epochs')[0])433 except:434 epochs = 4435 print(request.form.getlist('epochs')[0])436 print(request.form.getlist('validation_split')[0])437 validation_split = float(request.form.getlist('validation_split')[0])438 import dl_trainer439 file = os.path.splitext(filename)[0]440 a,bz = dl_trainer.dl_models(filename=file,model=6,aug=augmentation,epochs=epochs,validation_split=validation_split)441 global filename2442 filename2 = a443 global b444 b = bz445 return redirect(url_for('densenet121'))446 return render_template('upload_densenet121.html',something=str(b))447448@app.route('/densenet169_classifier', methods=['GET', 'POST'])449def densenet169():450 global filename451 if request.method == 'POST':452 print(request.form.getlist('augmentation')[0])453 try:454 augmentation = int(request.form.getlist('augmentation')[0])455 except:456 augmentation = 1457 try:458 epochs = int(request.form.getlist('epochs')[0])459 except:460 epochs = 4461 print(request.form.getlist('epochs')[0])462 print(request.form.getlist('validation_split')[0])463 validation_split = float(request.form.getlist('validation_split')[0])464 import dl_trainer465 file = os.path.splitext(filename)[0]466 a,bz = dl_trainer.dl_models(filename=file,model=7,aug=augmentation,epochs=epochs,validation_split=validation_split)467 global filename2468 filename2 = a469 global b470 b = bz471 return redirect(url_for('densenet169'))472 return render_template('upload_densenet169.html',something=str(b))473474@app.route('/densenet201_classifier', methods=['GET', 'POST'])475def densenet201():476 global filename477 if request.method == 'POST':478 print(request.form.getlist('augmentation')[0])479 try:480 augmentation = int(request.form.getlist('augmentation')[0])481 except:482 augmentation = 1483 try:484 epochs = int(request.form.getlist('epochs')[0])485 except:486 epochs = 4487 print(request.form.getlist('epochs')[0])488 print(request.form.getlist('validation_split')[0])489 validation_split = float(request.form.getlist('validation_split')[0])490 import dl_trainer491 file = os.path.splitext(filename)[0]492 a,bz = dl_trainer.dl_models(filename=file,model=8,aug=augmentation,epochs=epochs,validation_split=validation_split)493 global filename2494 filename2 = a495 global b496 b = bz497 return redirect(url_for('densenet201'))498 return render_template('upload_densenet201.html',something=str(b))499500@app.route('/densenet161_classifier', methods=['GET', 'POST'])501def densenet161():502 global filename503 if request.method == 'POST':504 print(request.form.getlist('augmentation')[0])505 try:506 augmentation = int(request.form.getlist('augmentation')[0])507 except:508 augmentation = 1509 try:510 epochs = int(request.form.getlist('epochs')[0])511 except:512 epochs = 4513 print(request.form.getlist('epochs')[0])514 print(request.form.getlist('validation_split')[0])515 validation_split = float(request.form.getlist('validation_split')[0])516 import dl_trainer517 file = os.path.splitext(filename)[0]518 a,bz = dl_trainer.dl_models(filename=file,model=9,aug=augmentation,epochs=epochs,validation_split=validation_split)519 global filename2520 filename2 = a521 global b522 b = bz523 return redirect(url_for('densenet161'))524 return render_template('upload_densenet161.html',something=str(b))525526@app.route('/alexnet_classifier', methods=['GET', 'POST'])527def alexnet():528 global filename529 if request.method == 'POST':530 print(request.form.getlist('augmentation')[0])531 try:532 augmentation = int(request.form.getlist('augmentation')[0])533 except:534 augmentation = 1535 try:536 epochs = int(request.form.getlist('epochs')[0])537 except:538 epochs = 4539 print(request.form.getlist('epochs')[0])540 print(request.form.getlist('validation_split')[0])541 validation_split = float(request.form.getlist('validation_split')[0])542 import dl_trainer543 file = os.path.splitext(filename)[0]544 a,bz = dl_trainer.dl_models(filename=file,model=10,aug=augmentation,epochs=epochs,validation_split=validation_split)545 global filename2546 filename2 = a547 global b548 b = bz549 return redirect(url_for('alexnet'))550 return render_template('upload_alexnet.html',something=str(b))551552@app.route('/squeezenet1_0_classifier', methods=['GET', 'POST'])553def squeezenet1_0():554 global filename555 if request.method == 'POST':556 print(request.form.getlist('augmentation')[0])557 try:558 augmentation = int(request.form.getlist('augmentation')[0])559 except:560 augmentation = 1561 try:562 epochs = int(request.form.getlist('epochs')[0])563 except:564 epochs = 4565 print(request.form.getlist('epochs')[0])566 print(request.form.getlist('validation_split')[0])567 validation_split = float(request.form.getlist('validation_split')[0])568 import dl_trainer569 file = os.path.splitext(filename)[0]570 a,bz = dl_trainer.dl_models(filename=file,model=11,aug=augmentation,epochs=epochs,validation_split=validation_split)571 global filename2572 filename2 = a573 global b574 b = bz575 return redirect(url_for('squeezenet1_0'))576 return render_template('upload_squeezenet1_0.html',something=str(b))577578@app.route('/squeezenet1_1_classifier', methods=['GET', 'POST'])579def squeezenet1_1():580 global filename581 if request.method == 'POST':582 print(request.form.getlist('augmentation')[0])583 try:584 augmentation = int(request.form.getlist('augmentation')[0])585 except:586 augmentation = 1587 try:588 epochs = int(request.form.getlist('epochs')[0])589 except:590 epochs = 4591 print(request.form.getlist('epochs')[0])592 print(request.form.getlist('validation_split')[0])593 validation_split = float(request.form.getlist('validation_split')[0])594 import dl_trainer595 file = os.path.splitext(filename)[0]596 a,bz = dl_trainer.dl_models(filename=file,model=12,aug=augmentation,epochs=epochs,validation_split=validation_split)597 global filename2598 filename2 = a599 global b600 b = bz601 return redirect(url_for('squeezenet1_1'))602 return render_template('upload_squeezenet1_1.html',something=str(b))603604@app.route('/vgg11_classifier', methods=['GET', 'POST'])605def vgg11():606 global filename607 if request.method == 'POST':608 print(request.form.getlist('augmentation')[0])609 try:610 augmentation = int(request.form.getlist('augmentation')[0])611 except:612 augmentation = 1613 try:614 epochs = int(request.form.getlist('epochs')[0])615 except:616 epochs = 4617 print(request.form.getlist('epochs')[0])618 print(request.form.getlist('validation_split')[0])619 validation_split = float(request.form.getlist('validation_split')[0])620 import dl_trainer621 file = os.path.splitext(filename)[0]622 a,bz = dl_trainer.dl_models(filename=file,model=13,aug=augmentation,epochs=epochs,validation_split=validation_split)623 global filename2624 filename2 = a625 global b626 b = bz627 return redirect(url_for('vgg11'))628 return render_template('upload_vgg11.html',something=str(b))629630@app.route('/vgg11_bn_classifier', methods=['GET', 'POST'])631def vgg11_bn():632 global filename633 if request.method == 'POST':634 print(request.form.getlist('augmentation')[0])635 try:636 augmentation = int(request.form.getlist('augmentation')[0])637 except:638 augmentation = 1639 try:640 epochs = int(request.form.getlist('epochs')[0])641 except:642 epochs = 4643 print(request.form.getlist('epochs')[0])644 print(request.form.getlist('validation_split')[0])645 validation_split = float(request.form.getlist('validation_split')[0])646 import dl_trainer647 file = os.path.splitext(filename)[0]648 a,bz = dl_trainer.dl_models(filename=file,model=14,aug=augmentation,epochs=epochs,validation_split=validation_split)649 global filename2650 filename2 = a651 global b652 b = bz653 return redirect(url_for('vgg11_bn'))654 return render_template('upload_vgg11_bn.html',something=str(b))655656@app.route('/vgg13_classifier', methods=['GET', 'POST'])657def vgg13():658 global filename659 if request.method == 'POST':660 print(request.form.getlist('augmentation')[0])661 try:662 augmentation = int(request.form.getlist('augmentation')[0])663 except:664 augmentation = 1665 try:666 epochs = int(request.form.getlist('epochs')[0])667 except:668 epochs = 4669 print(request.form.getlist('epochs')[0])670 print(request.form.getlist('validation_split')[0])671 validation_split = float(request.form.getlist('validation_split')[0])672 import dl_trainer673 file = os.path.splitext(filename)[0]674 a,bz = dl_trainer.dl_models(filename=file,model=15,aug=augmentation,epochs=epochs,validation_split=validation_split)675 global filename2676 filename2 = a677 global b678 b = bz679 return redirect(url_for('vgg13'))680 return render_template('upload_vgg13.html',something=str(b))681682@app.route('/vgg13_bn_classifier', methods=['GET', 'POST'])683def vgg13_bn():684 global filename685 if request.method == 'POST':686 print(request.form.getlist('augmentation')[0])687 try:688 augmentation = int(request.form.getlist('augmentation')[0])689 except:690 augmentation = 1691 try:692 epochs = int(request.form.getlist('epochs')[0])693 except:694 epochs = 4695 print(request.form.getlist('epochs')[0])696 print(request.form.getlist('validation_split')[0])697 validation_split = float(request.form.getlist('validation_split')[0])698 import dl_trainer699 file = os.path.splitext(filename)[0]700 a,bz = dl_trainer.dl_models(filename=file,model=16,aug=augmentation,epochs=epochs,validation_split=validation_split)701 global filename2702 filename2 = a703 global b704 b = bz705 return redirect(url_for('vgg13_bn'))706 return render_template('upload_vgg13_bn.html',something=str(b))707708@app.route('/vgg16_classifier', methods=['GET', 'POST'])709def vgg16():710 global filename711 if request.method == 'POST':712 print(request.form.getlist('augmentation')[0])713 try:714 augmentation = int(request.form.getlist('augmentation')[0])715 except:716 augmentation = 1717 try:718 epochs = int(request.form.getlist('epochs')[0])719 except:720 epochs = 4721 print(request.form.getlist('epochs')[0])722 print(request.form.getlist('validation_split')[0])723 validation_split = float(request.form.getlist('validation_split')[0])724 import dl_trainer725 file = os.path.splitext(filename)[0]726 a,bz = dl_trainer.dl_models(filename=file,model=17,aug=augmentation,epochs=epochs,validation_split=validation_split)727 global filename2728 filename2 = a729 global b730 b = bz731 return redirect(url_for('vgg16'))732 return render_template('upload_vgg16.html',something=str(b))733734@app.route('/vgg16_bn_classifier', methods=['GET', 'POST'])735def vgg16_bn():736 global filename737 if request.method == 'POST':738 print(request.form.getlist('augmentation')[0])739 try:740 augmentation = int(request.form.getlist('augmentation')[0])741 except:742 augmentation = 1743 try:744 epochs = int(request.form.getlist('epochs')[0])745 except:746 epochs = 4747 print(request.form.getlist('epochs')[0])748 print(request.form.getlist('validation_split')[0])749 validation_split = float(request.form.getlist('validation_split')[0])750 import dl_trainer751 file = os.path.splitext(filename)[0]752 a,bz = dl_trainer.dl_models(filename=file,model=18,aug=augmentation,epochs=epochs,validation_split=validation_split)753 global filename2754 filename2 = a755 global b756 b = bz757 return redirect(url_for('vgg16_bn'))758 return render_template('upload_vgg16_bn.html',something=str(b))759760@app.route('/vgg19_classifier', methods=['GET', 'POST'])761def vgg19():762 global filename763 if request.method == 'POST':764 print(request.form.getlist('augmentation')[0])765 try:766 augmentation = int(request.form.getlist('augmentation')[0])767 except:768 augmentation = 1769 try:770 epochs = int(request.form.getlist('epochs')[0])771 except:772 epochs = 4773 print(request.form.getlist('epochs')[0])774 print(request.form.getlist('validation_split')[0])775 validation_split = float(request.form.getlist('validation_split')[0])776 import dl_trainer777 file = os.path.splitext(filename)[0]778 a,bz = dl_trainer.dl_models(filename=file,model=19,aug=augmentation,epochs=epochs,validation_split=validation_split)779 global filename2780 filename2 = a781 global b782 b = bz783 return redirect(url_for('vgg19'))784 return render_template('upload_vgg19.html',something=str(b))785786@app.route('/vgg19_bn_classifier', methods=['GET', 'POST'])787def vgg19_bn():788 global filename789 if request.method == 'POST':790 print(request.form.getlist('augmentation')[0])791 try:792 augmentation = int(request.form.getlist('augmentation')[0])793 except:794 augmentation = 1795 try:796 epochs = int(request.form.getlist('epochs')[0])797 except:798 epochs = 4799 print(request.form.getlist('epochs')[0])800 print(request.form.getlist('validation_split')[0])801 validation_split = float(request.form.getlist('validation_split')[0])802 import dl_trainer803 file = os.path.splitext(filename)[0]804 a,bz = dl_trainer.dl_models(filename=file,model=20,aug=augmentation,epochs=epochs,validation_split=validation_split)805 global filename2806 filename2 = a807 global b808 b = bz809 return redirect(url_for('vgg19_bn'))810 return render_template('upload_vgg19_bn.html',something=str(b))811812if __name__ == "__main__":813 app.run()
...
NeuralNetUtil.py
Source:NeuralNetUtil.py
...22 if (lineNum >= limit):23 break24 return examples2526def getList(num,length):27 list = [0]*length28 list[num-1] = 129 return list30 31def getNNCarData(fileString ="datasets/car.data.txt", limit=100000 ):32 """33 returns limit # of examples from file passed as string34 """35 examples=[]36 attrValues={}37 data = open(fileString)38 attrs = ['buying','maint','doors','persons','lug_boot','safety']39 attr_values = [['vhigh', 'high', 'med', 'low'],40 ['vhigh', 'high', 'med', 'low'],41 ['2','3','4','5more'],42 ['2','4','more'],43 ['small', 'med', 'big'],44 ['high', 'med', 'low']]45 46 attrNNList = [('buying', {'vhigh' : getList(1,4), 'high' : getList(2,4), 'med' : getList(3,4), 'low' : getList(4,4)}),47 ('maint',{'vhigh' : getList(1,4), 'high' : getList(2,4), 'med' : getList(3,4), 'low' : getList(4,4)}),48 ('doors',{'2' : getList(1,4), '3' : getList(2,4), '4' : getList(3,4), '5more' : getList(4,4)}),49 ('persons',{'2' : getList(1,3), '4' : getList(2,3), 'more' : getList(3,3)}),50 ('lug_boot',{'small' : getList(1,3),'med' : getList(2,3),'big' : getList(3,3)}),51 ('safety',{'high' : getList(1,3), 'med' : getList(2,3),'low' : getList(3,3)})]5253 classNNList = {'unacc' : [1,0,0,0], 'acc' : [0,1,0,0], 'good' : [0,0,1,0], 'vgood' : [0,0,0,1]}54 55 for index in range(len(attrs)):56 attrValues[attrs[index]]=attrNNList[index][1]5758 lineNum = 059 for line in data:60 inVec = []61 outVec = []62 count=063 for val in line.split(','):64 if count==6:65 outVec = classNNList[val[:val.find('\n')]]66 else:67 inVec.append(attrValues[attrs[count]][val])68 count+=169 examples.append((inVec,outVec))70 lineNum += 171 if (lineNum >= limit):72 break73 random.shuffle(examples)74 return examples757677def buildExamplesFromPenData(size=10000):78 """79 build Neural-network friendly data struct80 81 pen data format82 16 input(attribute) values from 0 to 10083 10 possible output values, corresponding to a digit from 0 to 98485 """86 if (size != 10000):87 penDataTrainList = getNNPenData("datasets/pendigitsTrain.txt",int(.8*size))88 penDataTestList = getNNPenData("datasets/pendigitsTest.txt",int(.2*size))89 else : 90 penDataTrainList = getNNPenData("datasets/pendigitsTrain.txt")91 penDataTestList = getNNPenData("datasets/pendigitsTest.txt")92 return penDataTrainList, penDataTestList939495def buildExamplesFromCarData(size=200):96 """97 build Neural-network friendly data struct98 99 car data format100 | names file (C4.5 format) for car evaluation domain101102 | class values - 4 value output vector103104 unacc, acc, good, vgood105106 | attributes107108 buying: vhigh, high, med, low.109 maint: vhigh, high, med, low.110 doors: 2, 3, 4, 5more.111 persons: 2, 4, more.112 lug_boot: small, med, big.113 safety: low, med, high.114 """115 carData = getNNCarData()116 carDataTrainList = []117 for cdRec in carData:118 tmpInVec = []119 for cdInRec in cdRec[0] :120 for val in cdInRec :121 tmpInVec.append(val)122 #print "in :" + str(cdRec) + " in vec : " + str(tmpInVec)123 tmpList = (tmpInVec, cdRec[1])124 carDataTrainList.append(tmpList)125 #print "car data list : " + str(carDataList)126 tests = len(carDataTrainList)-size127 carDataTestList = [carDataTrainList.pop(random.randint(0,tests+size-t-1)) for t in xrange(tests)]128 return carDataTrainList, carDataTestList129 130131def buildPotentialHiddenLayers(numIns, numOuts):132 """133 This builds a list of lists of hidden layer layouts134 numIns - number of inputs for data135 some -suggestions- for hidden layers - no more than 2/3 # of input nodes per layer, and136 no more than 2x number of input nodes total (so up to 3 layers of 2/3 # ins max137 """138 resList = []139 tmpList = []140 maxNumNodes = max(numOuts+1, 2 * numIns)141 if (maxNumNodes > 15):142 maxNumNodes = 15143144 for lyr1cnt in range(numOuts,maxNumNodes):145 for lyr2cnt in range(numOuts-1,lyr1cnt+1):146 for lyr3cnt in range(numOuts-1,lyr2cnt+1):147 if (lyr2cnt == numOuts-1):148 lyr2cnt = 0149 150 if (lyr3cnt == numOuts-1):151 lyr3cnt = 0152 tmpList.append(lyr1cnt)153 tmpList.append(lyr2cnt)154 tmpList.append(lyr3cnt)155 resList.append(tmpList)156 tmpList = []157 return resList158159def getNNExtraData(fileString ="datasets/extra.txt", limit=10000 ):160 """161 returns limit # of examples from file passed as string162 """163 examples=[]164 attrValues={}165 data = open(fileString)166 attrs = ['top-left-square','top-middle-square','top-right-square','middle-left-square','middle-middle-square','middle-right-square',167 'bottom-left-square', 'bottom-middle-square', 'bottom-right-square']168 attr_values = [['x', 'o', 'b'],169 ['x', 'o', 'b'],170 ['x', 'o', 'b'],171 ['x', 'o', 'b'],172 ['x', 'o', 'b'],173 ['x', 'o', 'b'],174 ['x', 'o', 'b'],175 ['x', 'o', 'b'],176 ['x', 'o', 'b']]177 178 attrNNList = [('top-left-square', {'x' : getList(1,3), 'o' : getList(2,3), 'b' : getList(3,3)}),179 ('top-middle-square', {'x' : getList(1,3), 'o' : getList(2,3), 'b' : getList(3,3)}),180 ('top-right-square', {'x' : getList(1,3), 'o' : getList(2,3), 'b' : getList(3,3)}),181 ('middle-left-square', {'x' : getList(1,3), 'o' : getList(2,3), 'b' : getList(3,3)}),182 ('middle-middle-square', {'x' : getList(1,3), 'o' : getList(2,3), 'b' : getList(3,3)}),183 ('middle-right-square', {'x' : getList(1,3), 'o' : getList(2,3), 'b' : getList(3,3)}),184 ('bottom-left-square', {'x' : getList(1,3), 'o' : getList(2,3), 'b' : getList(3,3)}),185 ('bottom-middle-square', {'x' : getList(1,3), 'o' : getList(2,3), 'b' : getList(3,3)}),186 ('bottom-right-square', {'x' : getList(1,3), 'o' : getList(2,3), 'b' : getList(3,3)})]187188 classNNList = {'positive': [1,0], 'negative': [0,1]}189 190 for index in range(len(attrs)):191 attrValues[attrs[index]]=attrNNList[index][1]192193 lineNum = 0194 for line in data:195 inVec = []196 outVec = []197 count=0198 for val in line.split(','):199 if count==9:200 #print(lineNum)201 outVec = classNNList[val.strip()]202 else:203 inVec.append(attrValues[attrs[count]][val])204 count+=1205 examples.append((inVec,outVec))206 lineNum += 1207 if (lineNum >= limit):208 break209 random.shuffle(examples)210 return examples211212def getNNXORData(fileString="datasets/xordata.txt", limit=100000):213 """214 returns limit # of examples from penDigits file215 """216 examples=[]217 attrValues={}218 data = open(fileString)219 attrs = ['X','Y']220 attr_values = [['0', '1'], ['0', '1']]221 222 attrNNList = [('X', {'0' : getList(1,2), '1' : getList(2,2)}), ('Y',{'0' : getList(1,2), '1' : getList(2,2)})]223224 classNNList = {'0' : [1,0], '1' : [0,1]}225 226 for index in range(len(attrs)):227 attrValues[attrs[index]]=attrNNList[index][1]228229 lineNum = 0230 for line in data:231 inVec = []232 outVec = []233 count=0234 for val in line.split(','):235 if count==2:236 #print(type(val[:val.find('\n')]))
...
bitter.cgi
Source:bitter.cgi
1#!/usr/bin/python2# Accessed At3# http://cgi.cse.unsw.edu.au/~z3461601/ass2/bitter.cgi4import cgi, cgitb, glob, os, sys5import userActions6import viewPage7import bleatActions8cgitb.enable()9form = cgi.FieldStorage()10cookieCreated = None11# --------------------------------------------------------------------------------------------12# prints http header 13# --------------------------------------------------------------------------------------------14def httpHeader(cookie):15 if cookie:16 print "Content-Type: text/html"17 print cookie18 print ""19 else:20 print "Content-Type: text/html"21 print ""22 23 return24# --------------------------------------------------------------------------------------------25# Functions to handle all the back-end functions i.e. controller26# Each html form is an "operation" and the following ifs handle each operation appropriately27# --------------------------------------------------------------------------------------------28if "operation" in form and "Log In" in form.getlist("operation"):29 if userActions.checkLogin(form.getfirst("username"), form.getfirst("password")):30 cookieCreated = userActions.createSessionCookie(form.getfirst("username"))31 html = viewPage.userHome(form.getfirst("username"))32 else:33 html = viewPage.message("Incorrect Username or Password")34 35elif "operation" in form and "Sign Up" in form.getlist("operation"):36 if userActions.signUp(form.getfirst("username"), form.getfirst("fullName"), 37 form.getfirst("email"), form.getfirst("password")):38 html = viewPage.message("Account Created, Verification email sent")39 else:40 html = viewPage.message("Sorry that username is unavailable")41elif "operation" in form and "Log Out" in form.getlist("operation"):42 if userActions.isLoggedIn():43 userActions.logOut(userActions.getCurrentUser()) 44 cookieCreated = userActions.deleteSessionCookie()45 loginFile = open("html/login.html","r")46 html = loginFile.read()47 48elif "operation" in form and "search" in form.getlist("operation"):49 html = viewPage.search(form.getfirst("searchQuery"))50elif "operation" in form and "View Profile" in form.getlist("operation"):51 html = viewPage.userProfile(form.getfirst("username"))52elif "operation" in form and "Home" in form.getlist("operation"):53 html = viewPage.userHome(userActions.getCurrentUser())54elif "operation" in form and "Bleat" in form.getlist("operation"):55 bleatActions.insertBleat(userActions.getCurrentUser(),form.getfirst("bleatStr"))56 html = viewPage.userHome(userActions.getCurrentUser()) 57 #html = viewPage.test(userActions.getCurrentUser(), form.getfirst("bleatStr"))58elif "operation" in form and "Unlisten" in form.getlist("operation"):59 userActions.unlisten(form.getfirst("username"))60 html = viewPage.userProfile(form.getfirst("username")) # TEMP61 #show msg page/use js instead62elif "operation" in form and "Listen" in form.getlist("operation"):63 userActions.listen(form.getfirst("username"))64 html = viewPage.userProfile(form.getfirst("username")) #TEMP65 #show msg page/ use js instead66elif "operation" in form and "Reply" in form.getlist("operation"):67 html = viewPage.reply(form.getfirst("bleatID"))68elif "operation" in form and "Reply To Bleat" in form.getlist("operation"):69 bleatActions.replyToBleat(userActions.getCurrentUser(), form.getfirst("bleatid"), 70 form.getfirst("bleatStr"))71 html = viewPage.userHome(userActions.getCurrentUser())72elif "operation" in form and "verify" in form.getlist("operation"):73 userActions.verify(form.getfirst("user"))74 html = viewPage.message("Verified!")75 #show msg page76elif "operation" in form and "Settings" in form.getlist("operation"):77 html = viewPage.settings()78elif "operation" in form and "Update Account" in form.getlist("operation"): # TO DO79 userActions.updateAccount(userActions.getCurrentUser(), form.getfirst("password"), form.getfirst("email"), form.getfirst("fullName"), form.getfirst("homeLatitude"), form.getfirst("homeLongitude"),80 form.getfirst("homeSuburb"), form.getfirst("profileText"))81 html = viewPage.settings()82elif "operation" in form and "Suspend Account" in form.getlist("operation"):83 userActions.suspendAccount(userActions.getCurrentUser())84 html = viewPage.settings()85 86elif "operation" in form and "Unsuspend Account" in form.getlist("operation"):87 userActions.unsuspendAccount(userActions.getCurrentUser())88 html = viewPage.settings()89 90elif "operation" in form and "Delete Account" in form.getlist("operation"): #UNTESTED91 user = userActions.getCurrentUser()92 userActions.logOut(user) 93 userActions.deleteAccount(user)94 cookieCreated = userActions.deleteSessionCookie()95 loginFile = open("html/login.html","r")96 html = loginFile.read()97elif "operation" in form and "RecoverPassword" in form.getlist("operation"):98 if userActions.recoverPassword(form.getfirst("username")):99 html = viewPage.message("An email has been sent to your email address with instructions on how to recover your password")100 else:101 html = viewPage.message("Username doesn't exist")102elif "operation" in form and "Forgot Password" in form.getlist("operation"):103 forgotPassFile = open("html/forgotPassword.html")104 html = forgotPassFile.read()105elif "operation" in form and "resetPasswordView" in form.getlist("operation"):106 html = viewPage.resetPasswordView(form.getfirst("user"))107elif "operation" in form and "resetPassword" in form.getlist("operation"):108 userActions.resetPassword(form.getfirst("username"), form.getfirst("password"))109 loginFile = open("html/login.html","r")110 html = loginFile.read()111 112elif userActions.isLoggedIn(): #otherwise show the user their home page113 html = viewPage.userHome(userActions.getCurrentUser())114else: #otherwise show the login page115 loginFile = open("html/login.html","r")116 html = loginFile.read()117# Printing the HTML generated from the controller above118httpHeader(cookieCreated)...
restaurantLike.js
Source:restaurantLike.js
1let cnt = 0;2let tmpNum = -1;3function locationLoadSuccess(pos) {4 // íì¬ ìì¹ ë°ìì¤ê¸°5 var currentPos = new kakao.maps.LatLng(pos.coords.latitude, pos.coords.longitude);6 mylat = pos.coords.latitude;7 mylong = pos.coords.longitude;8 console.log("íì¬ìì¹ : " + currentPos + " íì
: " + typeof currentPos);9 restaurantSearch(mylat, mylong);10};11function locationLoadError(pos) {12 alert('ìì¹ ì 보를 ê°ì ¸ì¤ëë° ì¤í¨íìµëë¤.');13};14function searchRes(likelist) {15 console.log(likelist);16 navigator.geolocation.getCurrentPosition(locationLoadSuccess, locationLoadError);17};18function restaurantSearch(myY, myX) {19 console.log("**" + myY, myX);20 $.ajax({21 method: 'GET'22 , url: "https://dapi.kakao.com/v2/local/search/keyword.json"23 , data: {24 query: $("#restName").val() //ì¬ì©ìê° ê²ìí í¤ìë25 , category_group_code: "FD6" //ììì íí°ë§26 , x: myX //ì¤ì¬ì¢í X27 , y: myY //ì¤ì¬ì¢í Y28 , sort: "distance" //거리ì29 }30 , headers: {Authorization: "KakaoAK f1b2afc29adbbda05eea78825d075ca9"}31 })32 .done(function (data) {33 var getList = "";34 getList += "<table style='display:inline-block; border-collapse: separate; border-spacing: 0 10px;'>"35 for (var i = 0; i < data.documents.length; i++) {36 getList += "<tr>"37 getList += "<td> <a href='/detail?restaurant_id=" + data.documents[i].id + "' style='color:blue; text-decoration: none;'>" + data.documents[i].place_name + "</a></td>"38 getList += "<input type='hidden' value='" + data.documents[i].id + "'>"39 getList += "<input type='hidden' value='" + data.documents[i].place_name + "'>"40 getList += "<input type='hidden' value='" + data.documents[i].x + "'>"41 getList += "<input type='hidden' value='" + data.documents[i].y + "'>"42 getList += "<td>" + data.documents[i].phone + "</td>"43 getList += "<td>" + data.documents[i].category_name + "</td>"44 getList += "<td>" + data.documents[i].address_name + "</td>"45 getList += "<td>"46 getList += "<img src='like/default_like.png' id='likeimg" + i + "' width='50' height='50' onclick='javascript:saveData(" + i + ")' style='cursor: pointer'>"47 getList += "</td>"48 getList += "</tr>"49 }50 getList += "</table>"51 $("#restList").html("");52 $("#restList").html(getList);53 })54}55function enterkey() {56 if (window.event.keyCode == 13) {57 searchRes();58 }59}60function saveData(num) {61 var no = num * 5;62 var inputNum = num * 4 + 1;63 /*var str1 = document.getElementsByTagName('td')[no].childNodes[0].nodeValue; // id64 var str2 = document.getElementsByTagName('td')[no + 1].childNodes[0].nodeValue; // name*/65 var str3 = document.getElementsByTagName('td')[no + 1].childNodes[0].nodeValue; // phone66 var str4 = document.getElementsByTagName('td')[no + 3].childNodes[0].nodeValue; // address67 var str1 = document.getElementsByTagName('input')[inputNum + 1].value; // id68 var str2 = document.getElementsByTagName('input')[inputNum + 2].value; // name69 var x = document.getElementsByTagName('input')[inputNum + 3].value; // x70 var y = document.getElementsByTagName('input')[inputNum + 4].value; // y71 /*alert(x + ", "+ y);72 alert("ID: " + str1 + ", NAME: "+str2 + ", phone: "+str3 + ", 주ì: "+str4);*/73 const dataStr = {74 "restaurant_id": str1,75 "restaurant_name": str2,76 "phone": str3,77 "x": x,78 "y": y,79 "address": str480 }81 if (document.getElementById('likeimg' + num).src === "http://localhost:8084/like/default_like.png") {82 cnt += 1;83 $.ajax({84 method: 'POST',85 url: "/like",86 contentType: "application/json",87 dataType: "json",88 data: JSON.stringify(dataStr),89 success: function (data) {90 console.log("ì°í기 ì±ê³µ");91 },92 error: function (xhr, status, error) {93 console.log("ìë¬ë°ì");94 }95 });96 document.getElementById('likeimg' + num).src = 'like/like.png'97 }98 else {99 $.ajax({100 method: 'GET',101 url: "/myLikeDelete",102 contentType: "application/json",103 dataType: "json",104 data: {'restaurant_id': str1},105 success: function (data) {106 // if(data.proc == "success") {107 // console.log("DB ì ì¥ìë£")108 // }109 },110 error: function (xhr, status, error) {111 console.log("ìë¬ë°ì");112 }113 });114 cnt = 0;115 document.getElementById('likeimg' + num).src = 'like/default_like.png'116 }117 tmpNum = num;118 location.href = "#";119}120function checkdata(str){121 $.ajax({122 method: 'POST',123 url: "/checklikes",124 contentType: "application/json",125 dataType: "json",126 data: {'restaurant_id': str},127 success: function (data) {128 // if(data.proc == "success") {129 // console.log("DB ì ì¥ìë£")130 // }131 return true;132 },133 error: function (xhr, status, error) {134 console.log("ìë¬ë°ì!!");135 }136 });137 return false;...
Moneda.js
Source:Moneda.js
...26 });27 },28 addMoneda: function () {29 var Terr = this.getModel('Moneda');30 this.getList().getStore().insert(0, new Terr());31 this.getList().reMoneda.startEdit(0, 0);32 },33 editMoneda: function (grid, record) {34 if (this.getList().getSelectionModel().hasSelection()) {35 var selection = this.getList().getSelectionModel().getSelection()[0];36 this.getList().reMoneda.startEdit(selection, 0);37 } else {38 showMsg(0, futureLang.lbSelMod);39 }40 },41 delMoneda: function (grid, record) {42 var me = this;43 if (me.getList().getSelectionModel().hasSelection()) {44 var selection = this.getList().getSelectionModel().getSelection()[0];45 var nombMoneda = selection.data.moneda;46 function confirmar(btn) {47 if (btn === 'ok') {48 if (selection) {49 me.getList().getStore().remove(selection);50 }51 }52 }53 MensajeInterrogacion(Ext.lang.titles[2], Ext.String.format(futureLang.lbMsgConfirmar, nombMoneda), confirmar);54 } else {55 showMsg(0, futureLang.lbSelDel);56 }57 },58 toggleBtn: function (selModel, selections) {59 this.getList().down('#btnModificar').setDisabled(selections.length === 0);60 this.getList().down('#btnEliminar').setDisabled(selections.length === 0);61 },62 setExtraParams: function (store) {63 var me = this;64 if (me.getList().getSelectionModel().hasSelection()) {65 me.getMonedaStore().getProxy().extraParams = {66 pais: me.getList().getSelectionModel().getLastSelected().get('pais')67 };68 }69 }...
Sector.js
Source:Sector.js
...22 });23 },24 addSector: function() {25 var Sector = this.getModel('Sector');26 this.getList().getStore().insert(0, new Sector());27 this.getList().reSector.startEdit(0, 0);28 },29 editSector: function(grid, record) {30 var me = this;31 if (me.getList().getSelectionModel().hasSelection()) {32 var selection = me.getList().getSelectionModel().getSelection()[0];33 this.getList().reSector.startEdit(selection, 0);34 } else {35 showMsg(0, futureLang.lbSelMod);36 }37 },38 delSector: function(grid, record) {39 var me = this;40 if (me.getList().getSelectionModel().hasSelection()) {41 var selection = me.getList().getSelectionModel().getSelection()[0];42 function confirmar(btn) {43 if (btn === 'ok') {44 if (selection) {45 me.getList().getStore().remove(selection);46 }47 }48 }49 MensajeInterrogacion(Ext.lang.titles[2], futureLang.lbMsgConfirmar, confirmar);50 } else {51 showMsg(1, futureLang.lbSelDel);52 }53 },54 toggleBtn: function(selModel, selections) {55 this.getList().down('#btnModificar').setDisabled(selections.length === 0);56 this.getList().down('#btnEliminar').setDisabled(selections.length === 0);57 }...
Using AI Code Generation
1var trace = require('./tracetest');2trace.getList();3var trace = require('./tracetest');4trace.add(10,20);5var trace = require('./tracetest');6trace.sub(20,10);7var trace = require('./tracetest');8trace.mul(10,20);9var trace = require('./tracetest');10trace.div(20,10);
Using AI Code Generation
1var tracetest = require('tracetest');2var trace = new tracetest();3var list = trace.getList();4console.log(list);5var tracetest = function() {};6tracetest.prototype.getList = function() {7 return [1, 2, 3, 4];8};9module.exports = tracetest;
Using AI Code Generation
1var trace = require('./tracetest.js');2trace.getList();3var getList = function() {4 console.log('getList method called');5}6module.exports = {7};8var getList = require('./tracetest.js').getList;9getList();10var getList = require('./tracetest.js').getList;11getList();
Using AI Code Generation
1var tracetest = require('./tracetest.js');2tracetest.getList();3tracetest.getList();4tracetest.getList();5var list = [];6var getList = function () {7 list.push('test');8 console.log(list);9};10exports.getList = getList;
Using AI Code Generation
1var trace = require('./tracetest');2trace.getList();3var trace = {4 getList: function () {5 console.log("getList method called");6 }7}8module.exports = trace;9var trace = require('./tracetest');10trace.getList();11var trace = {12 getList: function () {13 console.log("getList method called");14 }15}16module.exports = trace;17var trace = require('./tracetest');18console.log(trace.getList);19var trace = {20 getList: function () {21 console.log("getList method called");22 }23}24module.exports = trace.getList;25var trace = require('./tracetest');26trace.getList();27var trace = {28 getList: function () {29 console.log("getList method called");30 }31}32module.exports = trace.getList;
Using AI Code Generation
1var tracetest = require('./tracetest.js');2tracetest.getList("test");3module.exports = {4 getList: function (name) {5 console.log(name);6 }7};
Using AI Code Generation
1const tracetest = require('./tracetest.js');2tracetest.getList();3exports.getList = function() {4 console.log('getList called');5}6Code: const tracetest = require('./tracetest.js');7Code: const tracetest = require('./tracetest.js');8tracetest.getList();9const tracetest = require('./tracetest.js');10tracetest.getList();11exports.getList = function() {12 console.log('getList called');13}14const tracetest = require('./tracetest.js');15tracetest.getList();
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!