+@app.route('/v1/inventry/table', methods=['GET'])
+def inventry_table():
+ """
+ return inventry table
+
+ :return: inventry table
+ """
+ retrive_info_db()
+ table = {"InventryData": listOfMsgs}
+ return jsonify(table)
+
+
+@app.route('/v1/inventry/image', methods=['GET'])
+def detected_image():
+ """
+ detect images with imposed
+
+ :return: result image
+ """
+ detected_image = app.config['UPLOAD_PATH'] + 'sample_image.jpg'
+ print('file exits:', str(path.exists(detected_image)))
+ status = str(path.exists(detected_image))
+ if status == 'True':
+ # as base64 string
+ with open(detected_image, "rb") as img_file:
+ jpeg_bin = base64.b64encode(img_file.read())
+
+ response = {'image': jpeg_bin}
+ return jsonify(response)
+ else:
+ response = {'image': 'null'}
+ print('file not exist')
+ return jsonify(response)
+
+
+def allowed_videofile(filename):
+ """
+ File types to upload:mp4
+ param: filename:
+ """
+ return '.' in filename and \
+ filename.rsplit('.', 1)[1].lower() in ALLOWED_VIDEO_EXTENSIONS
+
+
+@app.route('/v1/monitor/video', methods=['POST'])
+def upload_video():
+ app.logger.info("Received message from ClientIP [" + request.remote_addr
+ + "] Operation [" + request.method + "]" +
+ " Resource [" + request.url + "]")
+ print("videpath:" + app.config['VIDEO_PATH'])
+ if 'file' in request.files:
+ files = request.files.getlist("file")
+ for file in files:
+ if allowed_videofile(file.filename):
+ file.save(os.path.join(app.config['VIDEO_PATH'],
+ file.filename))
+ print('file path is:', app.config['VIDEO_PATH']
+ + file.filename)
+ else:
+ raise IOError('video format error')
+ msg = {"responce": "failure"}
+ return jsonify(msg)
+ msg = {"responce": "success"}
+ return jsonify(msg)
+
+
+def hash_func(camera_info):
+ hash_string = camera_info["cameraNumber"] + \
+ camera_info["cameraLocation"] + \
+ camera_info["rtspUrl"]
+ # readable_hash = hashlib.sha256(str(hash_string).encode(
+ # 'utf-8')).hexdigest()
+ readable_hash = hash(hash_string)
+ if readable_hash < 0:
+ readable_hash += sys.maxsize
+ print(readable_hash)
+ return readable_hash
+
+