-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
132 lines (102 loc) · 4.77 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# import os
# from dotenv import load_dotenv
# from flask import Flask
# from flask_caching import Cache
# from flask_mail import Mail, Message
# from flask_migrate import Migrate
# from flask_login import LoginManager
# from flask_sqlalchemy import SQLAlchemy
# from flask_wtf import CSRFProtect
# app = Flask(__name__)
# basedir = os.path.abspath(os.path.dirname(__file__))
# load_dotenv()
# #######################################
# # Flask-SQLAlchemy
# #######################################
# # app.config['SQLALCHEMY_DATABASE_URI'] = (
# # os.environ.get('DATABASE_URI') or 'sqlite:///' + os.path.join(basedir, 'test.db')
# # )
# app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(basedir, 'test.db')
# app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
# db = SQLAlchemy(app)
# migrate = Migrate(app, db)
# app.config['SQLALCHEMY_MIGRATE_REPO'] = os.path.join(basedir, 'db_repository')
# app.config['POSTGRES_PASSWORD'] = os.environ.get('POSTGRES_PASSWORD')
# #######################################
# # Flask-Security
# #######################################
# app.config['CSRF_ENABLED'] = True
# app.config['SECRET_KEY'] = os.environ.get('SECRET_KEY') or \
# 'you-will-never-guess'
# # allows new registrations to application
# app.config['SECURITY_REGISTERABLE'] = True
# csrf = CSRFProtect(app)
# #######################################
# # Flask-Login
# #######################################
# login_manager = LoginManager(app)
# login_manager.login_view = 'login'
# login_manager.login_message = "Авторизуйтесь для доступа к закрытым страницам"
# login_manager.login_message_category = "success"
# #######################################
# # Flask-Mail
# #######################################
# # to send automatic registration email to user
# # app.config['SECURITY_SEND_REGISTER_EMAIL'] = False
# app.config['MAIL_SERVER'] = 'smtp.yandex.ru'
# app.config['MAIL_PORT'] = 465
# # app.config['MAIL_USE_TLS'] = True
# app.config['MAIL_USERNAME'] = os.environ.get('MAIL_USERNAME') or 'YOU_MAIL@gmail.com'
# app.config['MAIL_PASSWORD'] = os.environ.get('MAIL_PASSWORD') or 'password'
# app.config['MAIL_DEFAULT_SENDER'] = app.config['MAIL_USERNAME']
# app.config['SECURITY_EMAIL_SENDER'] = app.config['MAIL_USERNAME']
# app.config['ADMINS'] = [app.config['MAIL_USERNAME']]
# app.config['MAIL_USE_TLS'] = False
# app.config['MAIL_USE_SSL'] = True
# mail = Mail(app)
# ######################################
# # Flask-Cache
# ######################################
# # app.config['CACHE_TYPE'] = os.environ.get('CACHE_TYPE') or 'SimpleCache'
# # app.config['CACHE_REDIS_HOST'] = os.environ.get('CACHE_REDIS_HOST') or 'localhost'
# # app.config['CACHE_REDIS_PORT'] = os.environ.get('CACHE_REDIS_PORT') or 6379
# # app.config['CACHE_REDIS_DB'] = os.environ.get('CACHE_REDIS_DB') or 0
# # app.config['CACHE_REDIS_URL'] = os.environ.get('CACHE_REDIS_URL') or None
# # app.config['CACHE_REDIS_PASSWORD'] = os.environ.get('CACHE_REDIS_PASSWORD')
# # app.config['CACHE_DEFAULT_TIMEOUT'] = os.environ.get('CACHE_DEFAULT_TIMEOUT') or 10
# # cache = Cache(app)
# ######################################
# # Upload Files
# ######################################
# app.config['UPLOAD_FOLDER'] = os.path.join(basedir, 'static', 'media', 'uploads/')
# app.config['ALLOWED_EXTENSIONS'] = {'png', 'jpg', 'jpeg', 'gif', 'md'}
# app.config['MAX_CONTENT_LENGTH'] = 16 * 1000 * 1000
# ######################################
# # Flask-Admin
# ######################################
# app.config['FLASK_ADMIN_SWATCH'] = 'cerulean'
# ###########################################################################
# # basedir = os.path.abspath(os.path.dirname(__file__))
# # app_dir = os.path.abspath(os.path.dirname(__file__))
# # class BaseConfig:
# # SECRET_KEY = os.environ.get('SECRET_KEY') or 'A SECRET KEY'
# # SQLALCHEMY_TRACK_MODIFICATIONS = False
# # # настройка Flask-Mail
# # MAIL_SERVER = 'smtp.googlemail.com'
# # MAIL_PORT = 587
# # MAIL_USE_TLS = True
# # MAIL_USERNAME = os.environ.get('MAIL_USERNAME') or 'YOU_MAIL@gmail.com'
# # MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD') or 'password'
# # MAIL_DEFAULT_SENDER = MAIL_USERNAME
# # class DevelopementConfig(BaseConfig):
# # DEBUG = True
# # SQLALCHEMY_DATABASE_URI = os.environ.get('DEVELOPMENT_DATABASE_URI') or \
# # 'sqlite:///' + os.path.join(basedir, 'test.db')
# # class TestingConfig(BaseConfig):
# # DEBUG = True
# # SQLALCHEMY_DATABASE_URI = os.environ.get('TESTING_DATABASE_URI') or \
# # 'sqlite:///' + os.path.join(basedir, 'test.db')
# # class ProductionConfig(BaseConfig):
# # DEBUG = False
# # SQLALCHEMY_DATABASE_URI = os.environ.get('PRODUCTION_DATABASE_URI') or \
# # 'sqlite:///' + os.path.join(basedir, 'test.db')