-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
118 lines (101 loc) · 4.03 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# 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
"""
DIALECT = 'mysql'
DRIVER = 'mysqldb'
USERNAME = os.environ.get('MYSQLUSER_FESTIVAL')
PASSWORD = os.environ.get('MYSQLPASSWORD_FESTIVAL')
HOST = os.environ.get('MYSQLHOST_FESTIVAL')
PORT = '3306'
DATABASE = 'culture_festival_4th'
class Config:
"""common configuration"""
SECRET_KEY = os.environ.get("SECRET_KEY") or "hard to guess string"
SQLALCHEMY_COMMIT_ON_TEARDOWN = True
SQLALCHEMY_RECORD_QUERIES = True
SQLALCHEMY_TRACK_MODIFICATIONS = True
ALLOWED_EXTENSIONS = ['zip', 'png', 'jpg', 'jpeg', 'pdf']
MAX_CONTENT_LENGTH = 30 * 1024 * 1024
BUPLOAD_FOLDER = os.path.join(basedir, "/upload")
#BUPLOAD_FOLDER = os.environ.get('BUPLOAD_FOLDER')
REDIS_URL = "redis://@localhost:6379/4"
CAPTCHA_ID = "b46d1900d0a894591916ea94ea91bd2c"
PRIVATE_KEY = "36fc3fe98530eea08dfc6ce76e3d24c4"
PIC_APPENDIX = ['png', 'jpg', 'jpeg', 'bmp', 'gif', 'zip']
RESOURCES_PER_PAGE=30
ACCESS_KEY = 'YCdnGHp2tRa7V0KDisHqXehlny0eVNM5vQow1cQV'
SECRET_KEY = 'ZGgkaNPunh6Y32FcsAtvhOd61rnlcKeeXPZ-qIlr'
URL = 'pchz6zd8k.bkt.clouddn.com'
QINIUNAME = 'festival'
@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 = "{}+{}://{}:{}@{}:{}/{}?charset=utf8".format(DIALECT,
DRIVER, USERNAME, PASSWORD, HOST, PORT,
DATABASE)
#os.environ.get('MYSQL_URI') or ("sqlite:///" + os.path.join(basedir, "data-dev.sqlite"))
# SQLALCHEMY_DATABASE_URI = os.environ.get('MYSQL_URI')
"""
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 = "{}+{}://{}:{}@{}:{}/{}?charset=utf8".format(DIALECT,
DRIVER, USERNAME, PASSWORD, HOST, PORT,
DATABASE)
#"sqlite:///" + os.path.join(basedir, "data-test.sqlite")
WTF_CSRF_ENABLED = False
# production configuration
class ProductionConfig(Config):
"""production configuration"""
SQLALCHEMY_DATABASE_URI = "{}+{}://{}:{}@{}:{}/{}?charset=utf8".format(DIALECT,
DRIVER, USERNAME, PASSWORD, HOST, PORT,
DATABASE)
#"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
}