Skip to content

Commit

Permalink
增加依赖,年度报告增加缺省页面
Browse files Browse the repository at this point in the history
  • Loading branch information
LC044 committed Dec 5, 2023
1 parent 6b1c866 commit 6d6b355
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 14 deletions.
60 changes: 46 additions & 14 deletions app/web_ui/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,17 @@ def index0():

@app.route('/home')
def home():
data = {
'sub_title': '二零二三年度报告',
'avatar_path': contact.avatar_path,
'nickname': contact.remark,
'first_time': msg_db.get_first_time_of_message(contact.wxid)[1],
}
return render_template('home.html', **data)
try:
data = {
'sub_title': '二零二三年度报告',
'avatar_path': contact.avatar_path,
'nickname': contact.remark,
'first_time': msg_db.get_first_time_of_message(contact.wxid)[1],
}
return render_template('home.html', **data)
except IndexError:
return set_text('咱就是说,一次都没聊过就别分析了')



@app.route('/wordcloud')
Expand All @@ -61,15 +65,43 @@ def one():
return render_template('wordcloud.html', **world_cloud_data)


def set_text(text):
html = '''
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Centered Text</title>
<style>
body {
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
}
.centered-text {
font-size: 2em;
text-align: center;
}
</style>
</head>
<body>
<div class="centered-text">
<!-- 这里是要显示的四个大字 -->
%s
</div>
</body>
</html>
''' % (text)
return html


@app.route('/test')
def test():
bar = (
Bar(init_opts=opts.InitOpts(theme=ThemeType.LIGHT))
.add_xaxis(["A", "B", "C", "D", "E"])
.add_yaxis("Series", [5, 20, 36, 10, 75])
.set_global_opts(title_opts=opts.TitleOpts(title="Flask and Pyecharts Interaction"))
)
return bar.dump_options_with_quotes()
return set_text('以下内容仅对VIP开放🐶')


def run(port=21314):
Expand Down
3 changes: 3 additions & 0 deletions requirements_pc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ fuzzywuzzy
python-Levenshtein
pillow
requests
flask==3.0.0
pyecharts==2.0.1
jieba==0.42.1

0 comments on commit 6d6b355

Please sign in to comment.