-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconfig.py
60 lines (45 loc) · 1.44 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
import os, logging
from sqlalchemy import create_engine
BASEDIR = os.path.dirname(os.path.abspath(__file__))
def sqlite_uri(db_name: str):
"""
generate sqlite url
"""
return 'sqlite:///{}'.format(os.path.join(BASEDIR, db_name))
class GeneralConfig:
SQLALCHEMY_TRACK_MODIFICATIONS = True
SECRET_KEY = os.urandom(14)
MAIL_HOST = 'smtp.mail.com'
MAIL_SENDER = ''
MAIL_PASSWORD = ''
MAIL_PORT = 587 # default port for tls
MAIL_USETLS = True
MAIL_USESSL = False
ALLOWED_EXTENSIONS = ['jpg','png','jpeg']
DIR_UPLOADS = os.path.join(BASEDIR, 'app/static/img')
class DevelopmentConfig(GeneralConfig):
"""
configuration for development mode
"""
SQLALCHEMY_DATABASE_URI = sqlite_uri('development.db')
LOG_LEVEL = logging.DEBUG
DEBUG = True
class ProductionConfig(GeneralConfig):
"""
using sqlite is not recomended in production enviroment
and sqlite cant used in heroku
"""
SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://uvYNtEWzlM:NpnKVWD4aa@remotemysql.com/uvYNtEWzlM'
DEBUG = False
class TestingConfig(GeneralConfig):
"""
configuration in testing mode
disabled csrf for testing authentication form
"""
SQLALCHEMY_DATABASE_URI = sqlite_uri('testing.db')
WTF_CSRF_ENABLED = False
TESTING = True
conf_obj = {'development':DevelopmentConfig,
'production':ProductionConfig,
'testing':TestingConfig
}