def scan(): if request.method == 'POST': if 'file' not in request.files: flash('No file part') return HTTPStatus.NO_CONTENT uploaded_files = request.files["file"] if uploaded_files and allowed_file(uploaded_files.filename): uploaded_files.save(uploaded_files.filename) # Renaming to app.apk source = uploaded_files.filename dest = 'app.apk' os.rename(source, dest) set_config_data('bytecode_scan_status', 'incomplete') thread_a = Compute(request.__copy__()) thread_a.start() main() while (True): time.sleep(2) if get_config_data('bytecode_scan_status') == 'complete': cleaner('app.apk') break thesid = get_config_data('scan_id') response = jsonify(status_code=HTTPStatus.OK, scan_id=thesid) # response = getreport(thesid) thesid = int(thesid) + 1 set_config_data('scan_id', str(thesid)) # os.system('rm app.apk') # response =jsonify{"status_code" = HTTPStatus.OK, "scan_id"= thesid} return response, {'Access-Control-Allow-Origin': '*'} return jsonify(status_msg="apk not sent properly")
def get_using_postgres(): error = {"error": "invalid params", "msg": ""} try: params = request.args err_msg, inputs = inp.getUrlInput(params) except Exception as e: #print(e) error['msg'] = "please provide valid params" return jsonify(error) if err_msg: error['msg'] = err_msg return jsonify(error) if "url" in inputs: scheme, netloc, path, query, fragment = urlparse.urlsplit( inputs["url"]) filename = os.path.basename(path) if modelRes.fileExist(filename): return jsonify({filename: "file already downloaded"}) else: # allocate id to download file id = random.randint(1, 1000000) if modelRes.checkid(id): id += random.randint(10, 10000) thread_a = modelRes.Compute(request.__copy__(), inputs["url"], id) thread_a.start() return jsonify({"file_id": id})
def post(self): """ Create iot event :return: """ r = request.__copy__() content = r.get_json(silent=True) process(content) response = jsonify(content) response.status_code = 201 return response
def process_swt_survey_webhook(): logger.info("Request received on /walkmesurvey") if request.is_json: payload = request.get_json() logger.debug(payload) logger.info("Processing Request") # process the request as a started event thread = Process(request.__copy__(), "survey") thread.start() return ("Accepted", 200) else: logger.error("Request is not json") return ("Invalid request", 400)
def post(self): if not request.json or not 'request_reff_id' in request.json: abort(400, description="Invalid Request") req_query = Scorem1Model.query.filter(Scorem1Model.reference_id == \ request.json['request_reff_id']).first() if req_query is None: abort(400, description="Reference Id not Found") else: try: db.session.rollback() thread_a = GetScorem1Result(request.__copy__()) thread_a.start() return jsonify({"ResultFlag": "True"}) except IntegrityError: db.session.rollback() return jsonify( {"ERROR": "Result already exist for this reference id"}), 400
def result(): if request.method == 'GET': return "get method invoked - THIS URL IS USED FOR POSTING. COME BACK WITH POST. GET OUT WITH YOUR GETS." else: # dictionary mapping for slash commands: # add class to link.py and add mapping switcher switcher = {'/link': Link} # obtain command class form switcher func = switcher.get(request.form['command'], lambda: "Invalid month") # start new command thread thread = func(request.__copy__()) thread.start() # confirm request received return 'Link request received'
def process_swt_started_webhook(): logger.info("Request received on /walkmestarted") if request.is_json: payload = request.get_json() # if not all(k in payload for k in required): # logger.error("Missing expected values") # logger.error(payload) # return ("Missing expected values", 400) logger.debug(payload) logger.info("Processing Request") # process the request as a started event thread = Process(request.__copy__(), "started") thread.start() return ("Accepted", 200) else: logger.error("Request is not json") return ("Invalid request", 400)
def process_task_webhook(): logger.info("Request received on /walkmetasks") # if Content-Type=application/json if request.is_json: payload = request.get_json() # if not all(k in payload for k in required): # logger.error("Missing expected values") # logger.error(payload) # return ("Missing expected values", 400) logger.debug(payload) logger.debug("Processing Request") # process the request as a task thread = Process(request.__copy__(), "task") thread.start() return ("Accepted", 200) else: logger.error("Request is not json") return ("Invalid request", 400)