-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
36 lines (33 loc) · 1.47 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
from dotenv import load_dotenv
basedir = os.path.abspath(os.path.dirname(__file__))
load_dotenv(os.path.join(basedir, '.env'))
class Config(object):
SECRET_KEY = os.environ.get('SECRET_KEY') or 'you-will-never-guess'
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \
'sqlite:///' + os.path.join(basedir, 'app.db')
SQLALCHEMY_TRACK_MODIFICATIONS = False
# 日志输出到控制台还是日志文件中
LOG_TO_STDOUT = os.environ.get('LOG_TO_STDOUT', 'false').lower() in ['true', 'on', '1']
# 邮件配置
ADMINS = [x.strip() for x in os.environ.get('ADMINS').split(',')] # 管理员的邮箱地址
MAIL_SERVER = os.environ.get('MAIL_SERVER')
MAIL_PORT = int(os.environ.get('MAIL_PORT') or 25)
MAIL_USE_SSL = os.environ.get('MAIL_USE_SSL', 'false').lower() in ['true', 'on', '1']
MAIL_USERNAME = os.environ.get('MAIL_USERNAME')
MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
MAIL_SENDER = os.environ.get('MAIL_SENDER')
# 分页设置
POSTS_PER_PAGE = 10
USERS_PER_PAGE = 10
COMMENTS_PER_PAGE = 10
MESSAGES_PER_PAGE = 10
TASKS_PER_PAGE = 10
# Redis 用于 RQ 任务队列
REDIS_URL = os.environ.get('REDIS_URL') or 'redis://'
# Elasticsearch 全文检索
ELASTICSEARCH_URL = os.environ.get('ELASTICSEARCH_URL') or '127.0.0.1:9200'
# Flask-Babel
BABEL_DEFAULT_LOCALE = 'en'
BABEL_DEFAULT_TIMEZONE = 'UTC'
LANGUAGES = ['zh', 'en']