Skip to content

Commit d394011

Browse files
authored
Create base64_to_image.py
1 parent 38315b4 commit d394011

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

python/base64_to_image.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)