-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.py
91 lines (77 loc) · 2.68 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# coding: utf-8
# config
# project base path
import os
basedir = os.path.abspath(os.path.dirname(__file__))
"""
common configuration
-- SECRET_KEY: secret key
-- SQLALCHEMY_COMMIT_ON_TEARDOWN: True
-- SQLALCHEMY_RECORD_QUERIES:
-- Can be used to explicitly disable or enable query recording.
Query recording automatically happens in debug or testing mode.
-- SQLALCHEMY_TRACK_MODIFICATIONS:
-- If set to True, Flask-SQLAlchemy will track modifications of
objects and emit signals.
The default is None, which enables tracking but issues a warning that
it will be disabled by default in the future.
This requires extra memory and should be disabled if not needed.
more configuration keys please see:
-- http://flask-sqlalchemy.pocoo.org/2.1/config/#configuration-keys
"""
class Config:
"""common configuration"""
SECRET_KEY = os.environ.get("SECRET_KEY") or "yzychl"
SQLALCHEMY_COMMIT_ON_TEARDOWN = True
SQLALCHEMY_RECORD_QUERIES = True
SQLALCHEMY_TRACK_MODIFICATIONS = True
FLASKY_MAIL_SUBJECT_PREFIX = "时光日记" # 邮件标题暂定
FLASKY_MAIL_SENDER = "admin" # 叫啥呢? 想不出来!
FLASKY_FOLLOWERS_PER_PAGE = 10 #待定
UPLOAD_FOLDER = '\diary\hah\upload' # 存图片的路径 ,暂定
ALLOWED_EXTENSIONS=set(['png','jpg','jpeg']) #可以选择的文件拓展名
FLASKY_COMMENTS_PER_PAGE = 10 # 待定
@staticmethod
def init_app(app):
pass
"""
development configuration
-- DEBUG: debug mode
-- SQLALCHEMY_DATABASE_URI:
-- The database URI that should be used for the connection.
more connection URI format:
-- Postgres:
-- postgresql://scott:tiger@localhost/mydatabase
-- MySQL:
-- mysql://scott:tiger@localhost/mydatabase
-- Oracle:
-- oracle://scott:[email protected]:1521/sidname
"""
class DevelopmentConfig(Config):
"""development configuration"""
DEBUG = True
SQLALCHEMY_DATABASE_URI = "sqlite:///" + os.path.join(basedir, "data-dev.sqlite")
"""
testing configuration
-- TESTING: True
-- WTF_CSRF_ENABLED:
-- in testing environment, we don't need CSRF enabled
"""
class TestingConfig(Config):
"""testing configuration"""
TESTING = True
SQLALCHEMY_DATABASE_URI = "sqlite:///" + os.path.join(basedir, "data-test.sqlite")
WTF_CSRF_ENABLED = False
# production configuration
class ProductionConfig(Config):
"""production configuration"""
SQLALCHEMY_DATABASE_URI = "sqlite:///" + os.path.join(basedir, "data.sqlite")
@classmethod
def init_app(cls, app):
Config.init_app(app)
config = {
"develop": DevelopmentConfig,
"testing": TestingConfig,
"production": ProductionConfig,
"default": DevelopmentConfig
}