From caa012dd9bf7251082dedec2db91355ce01284ab Mon Sep 17 00:00:00 2001 From: MarkusJoe Date: Fri, 18 Feb 2022 20:30:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=9A=84=E9=87=8D=E5=A4=A7bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 5 ++--- bin/utils/view.py | 10 +++------- db/count.db | Bin 12288 -> 12288 bytes 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/app.py b/app.py index 8071500..f5fb9e4 100644 --- a/app.py +++ b/app.py @@ -37,14 +37,13 @@ def build_page(name: str, length: int, theme: str) -> list[bool or Response] or """ count = fetch_data(name) if len(str(count)) > length: # 判断在数据库内的长度是否超过了设定的(或预设的)长度 - print('sdadada') return [False, ErrorProcess().too_lang_to_count(name)] if 7 <= length <= 10: # 判断设定的长度是否超过阈值 zero_count = '0' * (length - len(str(count))) + str(count) status, template = view_template(theme, length, name, zero_count) if status is True: return [True, template] - elif status == 'BadTheme': + else: return [False, 'BadTheme'] else: return [False, 'BadLength'] @@ -107,7 +106,7 @@ def main() -> Response or str: args = request.args name = str(args.get('name')).replace('None', 'null') theme = args.get('theme') - length = args.get('length') + length = str(args.get('length')).replace('None', '7') try: length = int(length) except ValueError: diff --git a/bin/utils/view.py b/bin/utils/view.py index 9c3cbde..b56e3c6 100644 --- a/bin/utils/view.py +++ b/bin/utils/view.py @@ -7,13 +7,12 @@ import sqlite3 -from typing import Tuple from flask import render_template from db.sqlite import fetch_style_data from db.sqlite import fetch_table -def view_template(style: str, length: int, name: str, count: str) -> str or tuple[bool, bool] or tuple[bool, str]: +def view_template(style: str, length: int, name: str, count: str) -> str or tuple[bool, str]: """ 渲染模板 :param count: @@ -23,11 +22,8 @@ def view_template(style: str, length: int, name: str, count: str) -> str or tupl :return: """ if style not in fetch_table(): - return 'BadLength' - try: - origin_data = fetch_style_data(style) # 获取数据库内的文件 - except sqlite3.OperationalError: - return False, False + return [False, 'BadLength'] + origin_data = fetch_style_data(style) # 获取数据库内的文件 context = [] if count != '0000000000': for i in count: # 通过elif语句依次判断数字 diff --git a/db/count.db b/db/count.db index 5d924c8ba299d63eb0618036f41c1fbbf901e174..5858b715c39594ef038c49bad4852bcfabb5f412 100644 GIT binary patch delta 104 zcmZojXh@hK&G=!Wj5FhhjR{Nm#W?wAG4Ma+|HS{2e<}Yt{v-T5`PcK$+N>zhz|YOe z$t=!ToRXN5Xfb)Id^}L?HU|DL{FnF-@ZaKp%>Rr34gWU&lbaP4=J0dDm2yr#pzi