feat:搭建项目结构

This commit is contained in:
Kakune55 2024-12-23 11:01:44 +08:00
parent fec24a50e0
commit aaf297717a
7 changed files with 53 additions and 0 deletions

4
conf/config.ini Normal file
View File

@ -0,0 +1,4 @@
[server]
listen = 0.0.0.0
port = 8080
debug = true

8
conf/util.py Normal file
View File

@ -0,0 +1,8 @@
import configparser
config_file_path = '/conf/config.ini'
config = configparser.ConfigParser()
def get_config_object(): return config
""" 返回配置对象 """

2
init.py Normal file
View File

@ -0,0 +1,2 @@
def init_all():
return

30
main.py Normal file
View File

@ -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'))

2
requirements.txt Normal file
View File

@ -0,0 +1,2 @@
Flask == 3.1.0
pymysql == 1.1.1

4
web/api.py Normal file
View File

@ -0,0 +1,4 @@
from flask import Blueprint
api_bp = Blueprint('api', __name__)

3
web/page.py Normal file
View File

@ -0,0 +1,3 @@
from flask import Blueprint
page_bp = Blueprint('page', __name__)