From aaf297717a1afc1f3c661e60ee68085041ad6e5c Mon Sep 17 00:00:00 2001 From: Kakune55 Date: Mon, 23 Dec 2024 11:01:44 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=90=AD=E5=BB=BA=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/config.ini | 4 ++++ conf/util.py | 8 ++++++++ init.py | 2 ++ main.py | 30 ++++++++++++++++++++++++++++++ requirements.txt | 2 ++ web/api.py | 4 ++++ web/page.py | 3 +++ 7 files changed, 53 insertions(+) create mode 100644 conf/config.ini create mode 100644 conf/util.py create mode 100644 init.py create mode 100644 main.py create mode 100644 requirements.txt create mode 100644 web/api.py create mode 100644 web/page.py diff --git a/conf/config.ini b/conf/config.ini new file mode 100644 index 0000000..00c9e5e --- /dev/null +++ b/conf/config.ini @@ -0,0 +1,4 @@ +[server] +listen = 0.0.0.0 +port = 8080 +debug = true diff --git a/conf/util.py b/conf/util.py new file mode 100644 index 0000000..eda96f8 --- /dev/null +++ b/conf/util.py @@ -0,0 +1,8 @@ +import configparser + +config_file_path = '/conf/config.ini' +config = configparser.ConfigParser() + + +def get_config_object(): return config +""" 返回配置对象 """ \ No newline at end of file diff --git a/init.py b/init.py new file mode 100644 index 0000000..0c84f2f --- /dev/null +++ b/init.py @@ -0,0 +1,2 @@ +def init_all(): + return \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..cfbeb84 --- /dev/null +++ b/main.py @@ -0,0 +1,30 @@ +from flask import * + +from init import init_all +from conf.util import * + +# from web import app +from web.api import api_bp +from web.page import page_bp + +app = Flask(__name__) + +# 获取配置对象 +conf = get_config_object() + +# 注册路由 +app.register_blueprint(api_bp) +app.register_blueprint(page_bp) + +# 启动 +if __name__ == '__main__': + # 初始化 + init_all() + + # 运行Kafka与Spark相关 + # run_kafka_spark() + + # 运行Web服务 + app.run(host=conf.get('web', 'host'), port=conf.get('web', 'port'), debug=conf.get('web', 'debug')) + + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..c7af6ff --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +Flask == 3.1.0 +pymysql == 1.1.1 \ No newline at end of file diff --git a/web/api.py b/web/api.py new file mode 100644 index 0000000..ca111ca --- /dev/null +++ b/web/api.py @@ -0,0 +1,4 @@ +from flask import Blueprint + +api_bp = Blueprint('api', __name__) + diff --git a/web/page.py b/web/page.py new file mode 100644 index 0000000..c18e1fa --- /dev/null +++ b/web/page.py @@ -0,0 +1,3 @@ +from flask import Blueprint + +page_bp = Blueprint('page', __name__) \ No newline at end of file