-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
75 lines (57 loc) · 2.1 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
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# Create by Albert_Chen
# CopyRight (py) 2017年 陈超. All rights reserved by Chao.Chen.
# Create on 2017-03-05
__author__ = 'Albert'
import os
base_dir = os.path.abspath(os.path.dirname(__file__))
class Config:
# Create dummy secrey key so we can use sessions
SECRET_KEY = 'dsfdgknaklndhlfsncdihsfldknvkfldkvniodhiofjrpongonroihfioehroihjgoirebviuhdeg'
# Flask-Security config
SECURITY_URL_PREFIX = "/admin"
SECURITY_PASSWORD_HASH = "pbkdf2_sha512"
SECURITY_PASSWORD_SALT = "ATGUOHAELKiubahiughaerGOJAEGj"
BABEL_DEFAULT_LOCALE = 'zh_CN'
# Flask-Security URLs, overridden because they don't put a / at the end
SECURITY_LOGIN_URL = "/login/"
SECURITY_LOGOUT_URL = "/logout/"
SECURITY_REGISTER_URL = "/register/"
SECURITY_POST_LOGIN_VIEW = "/admin/"
SECURITY_POST_LOGOUT_VIEW = "/admin/"
SECURITY_POST_REGISTER_VIEW = "/admin/"
# Flask-Security features
SECURITY_REGISTERABLE = True
SECURITY_SEND_REGISTER_EMAIL = False
SQLALCHEMY_TRACK_MODIFICATIONS = False
# Project BaseDIR
BASEDIR = os.path.abspath(os.path.dirname(__file__))
@staticmethod
def init_app(app):
pass
class DevelopmentConfig(Config):
# Create in-memory database
DEBUG = True
DATABASE_FILE = 'develop_db.sqlite'
DATABASE_PATH = os.path.join(base_dir, DATABASE_FILE)
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(base_dir, DATABASE_FILE)
SQLALCHEMY_ECHO = True
class ProductionConfig(Config):
DEBUG = False
DATABASE_FILE = 'db.sqlite'
DATABASE_PATH = os.path.join(base_dir, DATABASE_FILE)
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(base_dir, DATABASE_FILE)
SQLALCHEMY_ECHO = True
class TestConfig(Config):
TESTING = True
DATABASE_FILE = 'test_db.sqlite'
DATABASE_PATH = os.path.join(base_dir, DATABASE_FILE)
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(base_dir, DATABASE_FILE)
SQLALCHEMY_ECHO = True
config = {
"develop": DevelopmentConfig,
"product": ProductionConfig,
"test": TestConfig,
"default": DevelopmentConfig
}