Files
upload/config.py
T

61 lines
2.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
全局配置常量
"""
import os
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
TEMPLATES_DIR = os.path.join(BASE_DIR, 'templates')
STATIC_DIR = os.path.join(BASE_DIR, 'static')
DATA_DIR = os.path.join(BASE_DIR, 'data')
IMG_DIR = os.path.join(STATIC_DIR, 'img')
# 数据库路径由 db.py 统一管理(读取 config.yml)
# 如需获取 DB_PATH,请:from db import DB_PATH
# 兼容旧路径
FORMS_DIR = os.path.join(BASE_DIR, 'forms')
PRESETS_DIR = os.path.join(BASE_DIR, 'presets')
# Webhook 总开关;每个表单另需显式启用,默认不通知。设为 0 禁止所有对外通知。
NOTIFY_WEBHOOK = os.environ.get('UPLOAD_NOTIFY_WEBHOOK', '1') != '0'
# HTTPS 配置
from pathlib import Path
CERT_DIR = Path("/www/server/panel/vhost/cert/47.112.187.172")
CERT_FILE = CERT_DIR / "fullchain.pem"
KEY_FILE = CERT_DIR / "privkey.pem"
HTTP_PORT = int(os.environ.get('UPLOAD_PORT', '8080'))
# 智能列名识别关键词映射
FIELD_KEYWORDS = {
'idField': ['学号', 'studentid', 'id', '编号', 'no', '学号编号', '学生编号', 'student_id', '学号id'],
'nameField': ['姓名', 'name', '学生姓名', 'studentname', '学生名称', 'student_name', '名字'],
'idCardField': ['身份证', 'idcard', '身份证号', 'id_card', '证件号', '身份证号', 'identity'],
'phoneField': ['手机', '电话', 'phone', 'tel', 'mobile', '联系方式', '联系电话', '手机号'],
'groupField': ['班级', 'group', 'class', '班级名称', 'department', '年级', '专业']
}
# 可选依赖检测
try:
import pandas as pd
from difflib import SequenceMatcher
PANDAS_AVAILABLE = True
except ImportError:
PANDAS_AVAILABLE = False
print("警告: pandas未安装,名单预设管理功能将受限")
try:
import openpyxl
from openpyxl.styles import Font, PatternFill, Alignment, Border, Side
OPENPYXL_AVAILABLE = True
except ImportError:
OPENPYXL_AVAILABLE = False
print("警告: openpyxl未安装,Excel导出功能将受限")
try:
from PIL import Image
PIL_AVAILABLE = True
except ImportError:
PIL_AVAILABLE = False
print("警告: PIL/Pillow未安装,图标自动生成功能将不可用")