Change to support py 3.7

This commit is contained in:
Aaron Lee 2021-09-26 20:39:34 +08:00
parent 7254fed8a1
commit 430209717c

12
app.py
View file

@ -56,6 +56,12 @@ def verify_recaptcha(response):
return r.json()['success']
def removeprefix(s, prefix):
if s.startswith(prefix):
return s[len(prefix):]
return s
def manageProcess(fCommand, fData):
if (check_login_status()):
return redirect('/logout')
@ -304,7 +310,7 @@ def group_teach_publish():
if 'notes' in request.form:
notes = request.form['notes']
formData.pop('notes')
signature = signature.removeprefix('data:image/png;base64,')
signature = removeprefix(signature, 'data:image/png;base64,')
signature = bytes(signature, 'utf-8')
rand = str(date + '^' + cclass['category'] +
'^' + cclass['class_id'] + '^' + period)
@ -353,7 +359,7 @@ def homeroom_abs_publish():
if 'notes' in request.form:
notes = request.form['notes']
formData.pop('notes')
signature = signature.removeprefix('data:image/png;base64,')
signature = removeprefix(signature, 'data:image/png;base64,')
signature = bytes(signature, 'utf-8')
rand = str(date + '^' + homeroom[0] + '^' + homeroom[1] + '^' + period)
rand += ".png"
@ -384,7 +390,7 @@ def homeroom_confirm():
date = request.form['date']
homeroom = request.form['homeroom'].split('^')
signature = request.form['signatureData']
signature = signature.removeprefix('data:image/png;base64,')
signature = removeprefix(signature, 'data:image/png;base64,')
signature = bytes(signature, 'utf-8')
rand = str(date + '^' + homeroom[0] + '^' + homeroom[1] + '^' + 'hrCfrm')
rand += ".png"