feat:搭建项目结构
This commit is contained in:
		
							
								
								
									
										4
									
								
								conf/config.ini
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								conf/config.ini
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,4 @@
 | 
				
			|||||||
 | 
					[server]
 | 
				
			||||||
 | 
					listen = 0.0.0.0
 | 
				
			||||||
 | 
					port = 8080
 | 
				
			||||||
 | 
					debug = true
 | 
				
			||||||
							
								
								
									
										8
									
								
								conf/util.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								conf/util.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
				
			|||||||
 | 
					import configparser
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					config_file_path = '/conf/config.ini'
 | 
				
			||||||
 | 
					config = configparser.ConfigParser()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def get_config_object(): return config
 | 
				
			||||||
 | 
					""" 返回配置对象 """
 | 
				
			||||||
							
								
								
									
										30
									
								
								main.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								main.py
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										2
									
								
								requirements.txt
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,2 @@
 | 
				
			|||||||
 | 
					Flask == 3.1.0
 | 
				
			||||||
 | 
					pymysql == 1.1.1
 | 
				
			||||||
							
								
								
									
										4
									
								
								web/api.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								web/api.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,4 @@
 | 
				
			|||||||
 | 
					from flask import Blueprint
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					api_bp = Blueprint('api', __name__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										3
									
								
								web/page.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								web/page.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					from flask import Blueprint
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					page_bp = Blueprint('page', __name__)
 | 
				
			||||||
		Reference in New Issue
	
	Block a user