Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
충남대와 호환이되다니
  • Loading branch information
minseo0388 committed Sep 28, 2024
1 parent a450cb2 commit 0522bb3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 32 deletions.
8 changes: 2 additions & 6 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from flask import Flask, jsonify, g
from qr import image
import student
import qr

app = Flask(__name__)

Expand All @@ -11,10 +10,7 @@ def CNUqrhome():

@app.route('/cnuqr/<ID>', methods=['GET'])
def CNUqr(ID):
student.setStudentID(ID)
g.studentID = ID
return image.load("result.png")

return qr.qrmaker(ID).load("result.png")

@app.route('/cnuqr/getid', methods=['GET'])
def getID():
Expand Down
47 changes: 21 additions & 26 deletions qr.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,28 @@
import base64
import time, datetime
import qrcode
from studentinfo import studentID

# 교번 또는 학번을 입력받습니다.

# 코드 형식 조합
now = datetime.datetime.now()

year = str(now.year)
month = str(now.month)
day = str(now.day)
hour = str(now.hour)
minute = str(now.minute)
second = str(now.second)

newMonth = month.rjust(2,'0')
newDay = day.rjust(2,'0')
newHour = hour.rjust(2,'0')
newMinute = minute.rjust(2,'0')
newSecond = second.rjust(2,'0')

timeStamp = str(year + newMonth + newDay + newHour + newMinute + newSecond)

#Base64 형식으로 암호화
rawCode = str(studentID+"^"+timeStamp)
encodedCode = rawCode.encode('UTF-8')
resultCode = base64.b64encode(encodedCode)
resultCodeString = resultCode.decode('ascii')

# QR코드를 표출합니다.
image = qrcode.make(resultCodeString)
def qrmaker(studentID):
now = datetime.datetime.now()
year = str(now.year)
month = str(now.month)
day = str(now.day)
hour = str(now.hour)
minute = str(now.minute)
second = str(now.second)
newMonth = month.rjust(2,'0')
newDay = day.rjust(2,'0')
newHour = hour.rjust(2,'0')
newMinute = minute.rjust(2,'0')
newSecond = second.rjust(2,'0')
timeStamp = str(year + newMonth + newDay + newHour + newMinute + newSecond)
rawCode = str(studentID+"^"+timeStamp)
rawCode = str(studentID+"^"+timeStamp)
encodedCode = rawCode.encode('UTF-8')
resultCode = base64.b64encode(encodedCode)
resultCodeString = resultCode.decode('ascii')
image = qrcode.make(resultCodeString)
return image

0 comments on commit 0522bb3

Please sign in to comment.