def upload_file(): if request.method == 'POST': if 'file' not in request.files: flash('No file part') return redirect(request.url) file = request.files['file'] if file.filename == '': flash('No selected file') return redirect(request.url) if file and allowed_file(file.filename): ClaimServices.saveToDatabase(file) filename = secure_filename(file.filename) return redirect('/')
def getSnapshot(): try: os.remove(app.static_folder + '\snapshot.json') except Exception as e: pass mode = request.args.get('type') path_to_file = ClaimServices.exportDatabase(mode) return send_file(path_to_file, as_attachment=True, cache_timeout=-1)
def getDashboard(): if ClaimServices.databaseIsEmpty(): return render_template("getting_started.html") analysis = ClaimServices.analysis() return render_template("home.html", analysis=analysis)
def getNeural(): claim_id = request.args.get('id') print(claim_id) result = ClaimServices.getNeural(claim_id) return jsonify(result)
def getHistogram(): histogram = ClaimServices.getHistogram() return jsonify({"histogram": histogram})
def getAnalysis(): analysis = ClaimServices.analysis() analysis = json.dumps(analysis) analysis = json.loads(analysis) return jsonify(analysis)
def validateClaim(): data = request.json ClaimServices.validateClaim(data['id'], data['credible']) return jsonify({"success": True})
def getAllClaims(): claims = ClaimServices.getAllClaims() claims = json.dumps(claims) claims = json.loads(claims) return jsonify(claims)
def getUserCredAndModel(): result = ClaimServices.getUserCredAndModel() return jsonify(result)