From 6dd152a029f6d836aff703559b660f1343fc79c7 Mon Sep 17 00:00:00 2001 From: MarkusJoe Date: Sat, 9 Apr 2022 10:54:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E8=BF=94=E5=9B=9E=E5=B7=B2=E6=9C=89?= =?UTF-8?q?=E8=A1=A8=E7=9A=84=E6=8E=A5=E5=8F=A3=E5=9C=A8/api/=E4=B8=8B?= =?UTF-8?q?=E9=87=8D=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/main/views.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/app/main/views.py b/app/main/views.py index bc28b67..d0a746c 100644 --- a/app/main/views.py +++ b/app/main/views.py @@ -41,6 +41,8 @@ def api_v1(name: str): abort(500) if 7 <= length <= 10: data = db().fetch(name) + if len(str(data[-1])) > 10: + db().update(name, 0) # 使用设置的长度减去已有数据的长度, 将结果转换为string类型, 再和数据库内的数据进行拼接 number = '0' * (length - len(str(data[-1]))) + str(data[-1]) response = make_response(view(theme, int(length), name, number)) @@ -48,14 +50,3 @@ def api_v1(name: str): response.headers['cache-control'] = 'max-age=0, no-cache, no-store, must-revalidate' return response return abort(500) - - -@main.route('/exists-table', methods=['GET', 'POST']) -@main.route('/exists', methods=['GET', 'POST']) -def show_tables() -> Response: - """ - 返回已有表 - :return: - """ - tables = db().show_tables - return jsonify({'code': 200, 'msg': '已有表', 'data': [tables]})