This repository has been archived by the owner on Jun 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
53 lines (44 loc) · 2.71 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
import os
basedir = os.path.abspath(os.path.dirname(__file__))
# The configuration settings are defined as class variables inside the config
# class. As the application needs more configuration items, they can be added
# to this class, and later if theres need to have more than one configuration
# set, create subclasses to it.
# The SECRET_KEY configuration variable as the only configuration item is an
# important part in most Flask Applications. Flask and some of its extensions
# use the value of the secret key as a cryptographic key, useful to generate
# signatures or tokens.
# Flask WTF extension uses it to protect web forms against nasty attacks called
# Cross-Site Request Forgery.
class Config(object):
# The value of the secret key is set as an expression with two terms, joined
# by the or operator. The first term looks for the value of an environment
# variable, and the second is just a hardcoded string.
# The value sourced from an environment variable is preferred, but if the
# environment does not defined the variable, then the hardcoded string is used
SECRET_KEY = os.environ.get('SECRET_KEY') or 'you-will-never-guess'
# The Flask-SQLAlchemy extension takes the location of the application's
# database from the SQLALCHEMY_DATABASE_URI configuration variable. We take
# the database URL from the DATABASE_URL environment variable, and if that
# isn't defined, we configure a database named app.db located in the main di-
# rectory of the application, which is stored in the basedir variable
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or 'sqlite:///'\
+ os.path.join(basedir, 'app.db')
# The SQLALCHEMY_TRACK_MODIFICATIONS configuration option is set to False to
# disable a feature of Flask-SQLAlchemy that we do not need need, which is to
# signal the application every time a change is about to be made in the database
SQLALCHEMY_TRACK_MODIFICATIONS = False
# The Problem with the default error handling provided by Flask does not notify
# its producer, stack trace for errors are printed to the terminal, output of the
# server process needs to be monitored to discover errors. Its good to take proactive
# approaches regarding error. If an error occurs on the production version of the
# application, we configure an email to be sent
MAIL_SERVER = os.environ.get('MAIL_SERVER')
MAIL_PORT = int(os.environ.get('MAIL_PORT') or 25)
# Enable encrypted connections
MAIL_USE_TLS = os.environ.get('MAIL_USE_TLS') is not None
MAIL_USERNAME = os.environ.get('MAIL_USERNAME')
MAIL_USERNAME = os.environ.get('MAIL_PASSWORD')
ADMINS = ['[email protected]']
POSTS_PER_PAGE = 25
LANGUAGES = ['en', 'zh']