Skip to content

Commit eeb3345

Browse files
authored
Merge pull request #1 from pmh-only/main
Use filesystem to retrieve bytes data of qr code images
2 parents e470a05 + ff2787e commit eeb3345

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
1+
env/
22
/__pycache__
3+
4+
temp/*
5+
!temp/.gitkeep

app.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
from flask import Flask, jsonify, g
1+
from flask import Flask, jsonify, g, Response
22
import qr
3-
import qrcode
3+
import uuid
4+
import os
45

56
app = Flask(__name__)
67

@@ -11,7 +12,18 @@ def CNUqrhome():
1112

1213
@app.route('/cnuqr/<ID>', methods=['GET'])
1314
def CNUqr(ID):
14-
return qr.qrmaker(ID).load("result.png")
15+
qr_path = 'temp/' + str(uuid.uuid4()) + '.png'
16+
17+
qr.qrmaker(ID).save(qr_path)
18+
19+
qr_file = open(qr_path, "rb")
20+
qr_data = qr_file.read()
21+
qr_file.close()
22+
23+
os.remove(qr_path)
24+
25+
return Response(qr_data, mimetype="image/png")
26+
1527

1628
# @app.route('/cnuqr/getid', methods=['GET'])
1729
# def getID():

temp/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)