更新项目配置:添加.gitignore,清理日志和缓存文件,更新应用代码

This commit is contained in:
Hao Wang
2025-12-13 10:57:37 +08:00
parent f8a398d237
commit 66ef04b518
23 changed files with 216 additions and 1166 deletions

View File

@@ -3,8 +3,7 @@ Flask应用工厂
"""
import logging
from flask import Flask
from .config import DEBUG, SECRET_KEY, HOST, PORT
from .health import register_health_routes
from .config import DEBUG, HOST, PORT
from .routes.main import register_main_routes
def create_app():
@@ -15,13 +14,11 @@ def create_app():
# 配置
app.config['DEBUG'] = DEBUG
app.config['SECRET_KEY'] = SECRET_KEY
# 配置日志
configure_logging(app)
# 注册路由
register_health_routes(app)
register_main_routes(app)
return app
@@ -31,9 +28,16 @@ def configure_logging(app):
if not app.debug:
# 在生产环境中,将日志输出到文件
import logging
import os
from logging.handlers import RotatingFileHandler
file_handler = RotatingFileHandler('multi_camera.log', maxBytes=10240, backupCount=10)
# 日志目录
log_dir = './logs'
if not os.path.exists(log_dir):
os.makedirs(log_dir)
log_file = os.path.join(log_dir, 'multi_camera.log')
file_handler = RotatingFileHandler(log_file, maxBytes=10240, backupCount=10)
file_handler.setFormatter(logging.Formatter(
'%(asctime)s - %(levelname)s - %(message)s'
))