From ab2d805535cb59387e904538dbccf47588fcd0ac Mon Sep 17 00:00:00 2001 From: shuaikangzhou <863909694@qq.com> Date: Tue, 28 Nov 2023 21:32:24 +0800 Subject: [PATCH] add web --- .idea/workspace.xml | 199 +++++++++++++++++++------------------ app/resources/resource.qrc | 2 + app/web_ui/__init__.py | 0 app/web_ui/web.py | 48 +++++++++ 4 files changed, 150 insertions(+), 99 deletions(-) create mode 100644 app/web_ui/__init__.py create mode 100644 app/web_ui/web.py diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 9574c55..4eacf85 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -4,10 +4,11 @@ - - - - @@ -661,7 +658,6 @@ - @@ -672,7 +668,12 @@ - diff --git a/app/resources/resource.qrc b/app/resources/resource.qrc index 5f7e7e6..f71aa04 100644 --- a/app/resources/resource.qrc +++ b/app/resources/resource.qrc @@ -17,6 +17,8 @@ icons/search.svg icons/word.svg version_list.json + icons/logo.ico + icons/logo.png version_list.json diff --git a/app/web_ui/__init__.py b/app/web_ui/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/web_ui/web.py b/app/web_ui/web.py new file mode 100644 index 0000000..5edb71d --- /dev/null +++ b/app/web_ui/web.py @@ -0,0 +1,48 @@ +from flask import Flask, render_template +from pyecharts import options as opts +from pyecharts.charts import Bar +from pyecharts.globals import ThemeType + +app = Flask(__name__) + + +@app.route("/") +def index(): + # 创建一个简单的柱状图 + 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")) + ) + + # 将图表转换成 HTML + chart_html = bar.render_embed() + + # 渲染模板,并传递图表的 HTML 到模板中 + return render_template("index.html", chart_html=chart_html) + + +@app.route("/index") +def index0(): + return render_template("index.html") + + +@app.route('/home') +def home(): + data = { + 'sub_title': '二零二三年度报告', + 'avatar_path': "static/my_resource/avatar.png", + 'nickname': '司小远', + 'first_time': '2023-09-18 20:39:08', + } + return render_template('home.html', **data) + + +@app.route('/message_num') +def one(): + return "1hello world" + + +if __name__ == "__main__": + app.run(debug=True, host='0.0.0.0')