There was an error while loading. Please reload this page.
1 parent 38315b4 commit d394011Copy full SHA for d394011
python/base64_to_image.py
@@ -0,0 +1,18 @@
1
+SAVE_DIR = os.path.dirname(os.path.abspath(__file__))
2
+
3
+def base64_to_image(filename):
4
+ path = os.path.join(SAVE_DIR, 'images/')
5
+ if not os.path.isdir(path):
6
+ os.mkdir(path)
7
+ data = base64.b64decode(filename)
8
+ filename = 'frame' + str(datetime.datetime.now().microsecond) + '.jpg'
9
+ destination = "/".join([path, filename])
10
+ with open(destination, 'wb') as f:
11
+ f.write(data)
12
+ return "success", 201
13
+# @app.route('/frame/upload/', methods=['GET', 'POST'])
14
+# def upload_image():
15
+# if request.method == "POST":
16
+# file = request.form['images']
17
+# convert_to_image(file)
18
+# return "Successfully", 201
0 commit comments