From 2584de860d38b42bd0ed8843b6ec4c257ee8b3f7 Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Fri, 16 Jul 2021 18:13:07 +0800 Subject: [PATCH] main.py: article count. --- app/main.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/main.py b/app/main.py index 50b2146..9008101 100644 --- a/app/main.py +++ b/app/main.py @@ -30,6 +30,13 @@ def get_random_ads(): ads = random.choice(['个性化分析精准提升', '你的专有单词本', '智能捕捉阅读弱点,针对性提高你的阅读水平']) return ads + '。 试试吧!' +def total_number_of_essays(): + rq = RecordQuery(path_prefix + 'static/wordfreqapp.db') + rq.instructions("SELECT * FROM article") + rq.do() + result = rq.get_results() + return len(result) + def load_freq_history(path): d = {} if os.path.exists(path): @@ -235,6 +242,7 @@ def mainpage(): page += '

登录 成为会员 使用说明

\n' #page += '

advertisement

' % (get_random_image(path_prefix + 'static/img/')) page += '

%s

' % (get_random_ads()) + page += '

共有文章%d篇' % (total_number_of_essays()) page += '

粘帖1篇文章 (English only)

' page += '
' page += '
'