From fc2812b33ac147423215a1557e30049b0dfe6809 Mon Sep 17 00:00:00 2001 From: minseo0388 Date: Sat, 28 Sep 2024 01:02:15 +0900 Subject: [PATCH] Update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit unsupported operand type(s) for +: 'NoneType' and 'str' 해결해야함 --- .gitignore | 2 + LICENSE | 2 +- README.md | 4 +- app.py | 20 ++++++++++ qrcode.py => qr.py | 91 ++++++++++++++++++++++------------------------ studentinfo.py | 8 ++++ 6 files changed, 76 insertions(+), 51 deletions(-) create mode 100644 app.py rename qrcode.py => qr.py (78%) create mode 100644 studentinfo.py diff --git a/.gitignore b/.gitignore index f123828..afd4762 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ __pycache__/qrcode.cpython-312.pyc __pycache__/result.png +__pycache__/studentinfo.cpython-312.pyc +/__pycache__ diff --git a/LICENSE b/LICENSE index 3eb19f1..aa8c0ed 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -CNUqrcode Software License - Version 1.0 - September 27, 2024 +CNUqrweb Software License - Version 1.0 - September 27, 2024 Permission is hereby granted when there is no consent from Chungnam National University to publish the software code related to Chungnam National diff --git a/README.md b/README.md index 7ff94b1..bb106f3 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -# CNUqrcode -충남대학교 본인인증 QR코드 생성기 +# CNUqrweb +충남대학교 본인인증 QR코드 생성 웹사이트 diff --git a/app.py b/app.py new file mode 100644 index 0000000..d255956 --- /dev/null +++ b/app.py @@ -0,0 +1,20 @@ +from flask import Flask, jsonify +from qr import image +import studentinfo + +app = Flask(__name__) + +@app.route('/') +@app.route('/cnuqr') +def cnuqrhome(): + return '/cnuqr/학번 형식으로 접속해주세요. System Operational.' + +@app.route('/cnuqr/', methods=['GET']) +def handleCNUqr(ID): + studentinfo.setStudentID(ID) + return image.load("result.png") + +if __name__ == '__main__': + app.run('127.0.0.1', 5000, debug=True) + +# 설정시 다시 작동. \ No newline at end of file diff --git a/qrcode.py b/qr.py similarity index 78% rename from qrcode.py rename to qr.py index 6bf3693..e394fdd 100644 --- a/qrcode.py +++ b/qr.py @@ -1,48 +1,43 @@ -# 여기에 코드를 입력하세요. - -# 충남대학교 도서관 어플리케이션과 충남대학교 공식 앱에 뜨는 -# 본인 확인용 QR코드 생성 코드입니다. - -# 이미지가 다운로드 되면 성공입니다. - -# 제작자 : 화학과 24 최민서 - -# 필요한 라이브러리를 import합니다. -import base64 -import time, datetime -import qrcode - -# 교번 또는 학번을 입력받습니다. -studentID = str(input("학번 또는 교번을 입력하십시오 : ")) - -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') - -print(resultCodeString) - -# QR코드를 표출합니다. -image = qrcode.make(resultCodeString) -image.save("result.png") \ No newline at end of file +# 여기에 코드를 입력하세요. + +# 충남대학교 도서관 어플리케이션과 충남대학교 공식 앱에 뜨는 +# 본인 확인용 QR코드 생성 코드입니다. + +# 이미지가 다운로드 되면 성공입니다. + +# 제작자 : 화학과 24 최민서 + +# 필요한 라이브러리를 import합니다. +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) \ No newline at end of file diff --git a/studentinfo.py b/studentinfo.py new file mode 100644 index 0000000..8704830 --- /dev/null +++ b/studentinfo.py @@ -0,0 +1,8 @@ +studentID = None + +def setStudentID(ID): + global studentID + studentID = ID + +def getStudentID(): + return studentID \ No newline at end of file