Files
FileCodeBox/core/settings.py
T

74 lines
2.6 KiB
Python
Raw Normal View History

2023-08-15 10:05:50 +08:00
# @Time : 2023/8/15 09:51
# @Author : Lan
# @File : settings.py
# @Software: PyCharm
import json
2023-08-15 10:05:50 +08:00
from pathlib import Path
2024-01-18 18:31:11 +08:00
BASE_DIR = Path(__file__).resolve().parent.parent
data_root = BASE_DIR / 'data'
2023-08-15 10:05:50 +08:00
if not data_root.exists():
data_root.mkdir(parents=True, exist_ok=True)
DEFAULT_CONFIG = {
2023-08-15 20:50:19 +08:00
'file_storage': 'local',
2023-08-15 17:23:30 +08:00
'name': '文件快递柜-FileCodeBox',
'description': '开箱即用的文件快传系统',
'notify_title': '系统通知',
'notify_content': '欢迎使用FileCodeBox,本程序开源于 <a href="https://github.com/vastsa/FileCodeBox" target="_blank">Github</a> ,欢迎Star和Fork。',
'page_explain': '根据《中华人民共和国网络安全法》、《中华人民共和国刑法》、《中华人民共和国治安管理处罚法》等相关规定。 传播或存储违法、违规内容,会受到相关处罚,严重者将承担刑事责任。请勿上传非法文件,本站坚决配合相关部门,确保网络内容的安全,和谐,打造绿色网络环境。',
2023-12-30 18:19:15 +08:00
'keywords': 'FileCodeBox, 文件快递柜, 口令传送箱, 匿名口令分享文本, 文件',
2023-08-15 17:23:30 +08:00
's3_access_key_id': '',
's3_secret_access_key': '',
's3_bucket_name': '',
's3_endpoint_url': '',
's3_region_name': 'auto',
's3_signature_version': 's3v2',
2023-12-30 18:19:15 +08:00
's3_hostname': '',
's3_proxy': 0,
'max_save_seconds': 0,
2023-10-24 14:02:28 +08:00
'aws_session_token': '',
2023-08-18 20:00:48 +08:00
'onedrive_domain': '',
'onedrive_client_id': '',
'onedrive_username': '',
'onedrive_password': '',
'onedrive_root_path': 'filebox_storage',
'onedrive_proxy': 0,
2023-08-15 20:18:04 +08:00
'admin_token': 'FileCodeBox2023',
2023-08-15 17:23:30 +08:00
'openUpload': 1,
'uploadSize': 1024 * 1024 * 10,
'expireStyle': ['day', 'hour', 'minute', 'forever', 'count'],
2023-08-15 17:23:30 +08:00
'uploadMinute': 1,
'opacity': 0.9,
'background': '',
2023-08-15 17:23:30 +08:00
'uploadCount': 10,
'errorMinute': 1,
'errorCount': 1,
2023-08-18 20:00:48 +08:00
'port': 12345,
2023-08-15 17:23:30 +08:00
}
class Settings:
def __init__(self, defaults=None):
self.default_config = defaults or {}
self.user_config = {}
2023-08-15 17:23:30 +08:00
def __getattr__(self, attr):
if attr in self.user_config:
return self.user_config[attr]
if attr in self.default_config:
return self.default_config[attr]
raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{attr}'")
2023-08-15 17:23:30 +08:00
def __setattr__(self, key, value):
if key in ['default_config', 'user_config']:
super().__setattr__(key, value)
else:
self.user_config[key] = value
2023-08-15 17:23:30 +08:00
2023-08-24 14:04:00 +08:00
def items(self):
return {**self.default_config, **self.user_config}.items()
2023-08-24 14:04:00 +08:00
2024-01-18 18:31:11 +08:00
settings = Settings(DEFAULT_CONFIG)