From 41e4ecf04ce0e5cfa1a1e95fce546fcb6d4d68a6 Mon Sep 17 00:00:00 2001 From: Tdxdxoz Date: Wed, 30 Dec 2020 22:20:44 +0800 Subject: [PATCH] feat: show count info at login page --- app.py | 4 ++++ gen_wechat_html.py | 18 +++++++++++++++++- static/login/index.html | 42 ++--------------------------------------- 3 files changed, 23 insertions(+), 41 deletions(-) diff --git a/app.py b/app.py index 21b83a8..d7b2472 100644 --- a/app.py +++ b/app.py @@ -104,6 +104,10 @@ def login_required(allow_guest=True): def login(): return app.send_static_file('login/index.html') +@app.route('/pastExam/login/count-info.html') +def login_count_info(): + return app.send_static_file('login/count-info.html') + @app.route('/pastExam/logout') def logout(): session.pop('username', None) diff --git a/gen_wechat_html.py b/gen_wechat_html.py index 6a94470..6d09633 100644 --- a/gen_wechat_html.py +++ b/gen_wechat_html.py @@ -28,6 +28,19 @@ html_text = ''' ''' +local_html_text = ''' + + + + + + + +

目前这里有{nc}门课程的{np}份资料
欢迎继续添砖加瓦

+ + +''' + def check_and_update(last_number): np = Paper.query.count() if np != last_number: @@ -38,6 +51,9 @@ def check_and_update(last_number): ssh.load_system_host_keys() ssh.connect(host, username=username) + with open('static/login/count-info.html', 'w') as f: + f.write(local_html_text.format(nc=nc, np=np, target_host=target_host)) + with SCPClient(ssh.get_transport()) as scp: fl = io.BytesIO() fl.write(bytes(html_text.format(time=t.strftime("%Y-%m-%d %H:%M"), nc=nc, np=np, target_host=target_host), encoding='utf-8')) @@ -47,7 +63,7 @@ def check_and_update(last_number): return np -n = 0 +n = check_and_update(0) while True: try: print(str(datetime.now()), 'start ------') diff --git a/static/login/index.html b/static/login/index.html index 0ba7eb2..08ef6df 100644 --- a/static/login/index.html +++ b/static/login/index.html @@ -45,29 +45,6 @@ color: inherit; text-decoration: underline; } - - .wechat-mask { - position: fixed; - width: 100%; - height: 100%; - top: 0; - left: 0; - text-align: center; - padding-top: 50px; - background: #000e; - display: none; - } - - .wechat-mask p { - position: relative; - top: 36%; - transform: translateY(-50%); - color: white; - font-size: 28px;; - font-family: 'Noto Serif SC', serif; - font-weight: 700; - } - @@ -93,17 +70,13 @@

消除信息不对等,追求更有意义的评价体系

+ -
-

检测到处于非规范环境
(如微信内置浏览器)

- 如需使用请点击右上角
“在浏览器中打开”

- 如需在微信中传播分享
可直接分享本页面 -