-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
45 lines (37 loc) · 1.35 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
37
38
39
40
41
42
43
44
45
import os
basedir = os.path.abspath(os.path.dirname(__file__))
class Config(object):
SECRET_KEY = os.environ.get('SECRET_KEY') or "i don't want tell you"
SQLALCHEMY_COMMIT_ON_TEARDOWN = True
SQLALCHEMY_TRACK_MODIFICATIONS = True
MAIL_SERVER = 'smtp.sina.com'
MAIL_PORT = 25
MAIL_USERNAME = '[email protected]'
MAIL_PASSWORD = 'sina.com.cn'
MAIL_SENDER = '博客管理员 <[email protected]>'
FLASKY_ADMIN = '[email protected]'
# 文章列表页面每页显示文章数量
POSTS_PER_PAGE = 10
# 评论列表每页显示评论数量
COMENTS_PER_PAGE = 20
# 后台列表页每页显示数量
ADMIN_PER_PAGE = 20
@staticmethod
def init_app(app):
pass
class DevelopmentConfig(Config):
DEBUG = True
# SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'data-dev.sqlite')
SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://root:root@localhost/flask_web'
# 用于测试配置
class TestingConfig(Config):
TESTING = True
SQLALCHEMY_DATABASE_URI = 'sqlite:///'+os.path.join(basedir, 'data-test.sqlite')
# 用于生产服务器
class ProductionConfig(Config):
SQLALCHEMY_DATABASE_URI = 'sqlite:///'+os.path.join(basedir, 'data.sqlite')
config = {
'development': DevelopmentConfig,
'testing': TestingConfig,
'production': ProductionConfig,
'default': DevelopmentConfig}