From 6c2a9823afce59bf7d4edc765a7fa31b212d12f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E6=80=9D=E6=80=A1?= <912465467@qq.com> Date: Sat, 6 May 2023 19:08:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=86=E5=8E=9F=E6=9D=A5?= =?UTF-8?q?=E5=90=8C=E5=AD=A6=E7=9A=84=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api_bp.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/api_bp.py b/app/api_bp.py index 45cd5ea..59e2113 100644 --- a/app/api_bp.py +++ b/app/api_bp.py @@ -1,8 +1,7 @@ import json + from flask import Blueprint -from wordfreqCMD import * -from Article import get_today_article, load_freq_history -import pickle_idea + import pickle_idea2 path_prefix = '/var/www/wordfreq/wordfreq/' @@ -16,7 +15,7 @@ def helper(res, result): for item in res: if type(res[str(item)]) == 'dict': helper(res[str(item)], result) - if type(res[str(item)])== 'list': + if type(res[str(item)]) == 'list': for i in range(len(res[str(item)])): helper(res[str(item)][i], result) result.append(str(item)) @@ -29,11 +28,11 @@ def api_bp(username): result = [] user_freq_record = path_prefix + 'static/frequency/' + 'frequency_%s.pickle' % (username) s = pickle_idea2.load_record(user_freq_record) - wordlist = helper(s,result) + wordlist = helper(s, result) print(json.dumps(s)) results = {} for word in wordlist: results[word] = len(s[word]) - return results \ No newline at end of file + return results