From 430209717c5eb59972be1ae51cc824d4f25ab8eb Mon Sep 17 00:00:00 2001 From: Aaron Lee Date: Sun, 26 Sep 2021 20:39:34 +0800 Subject: [PATCH] Change to support py 3.7 --- app.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index 5d465b2..060f8fa 100644 --- a/app.py +++ b/app.py @@ -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"