forked from miguelgrinberg/microblog-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
46 lines (38 loc) · 1.76 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
import os
from dotenv import load_dotenv
load_dotenv()
basedir = os.path.abspath(os.path.dirname(__file__))
def as_bool(value):
if value:
return value.lower() in ['true', 'yes', 'on', '1']
return False
class Config:
# database options
ALCHEMICAL_DATABASE_URL = os.environ.get('DATABASE_URL') or \
'sqlite:///' + os.path.join(basedir, 'db.sqlite')
ALCHEMICAL_ENGINE_OPTIONS = {'echo': as_bool(os.environ.get('SQL_ECHO'))}
# security options
SECRET_KEY = os.environ.get('SECRET_KEY', 'top-secret!')
DISABLE_AUTH = as_bool(os.environ.get('DISABLE_AUTH'))
ACCESS_TOKEN_MINUTES = int(os.environ.get('ACCESS_TOKEN_MINUTES') or '15')
REFRESH_TOKEN_DAYS = int(os.environ.get('REFRESH_TOKEN_DAYS') or '7')
REFRESH_TOKEN_IN_COOKIE = as_bool(os.environ.get(
'REFRESH_TOKEN_IN_COOKIE') or 'yes')
REFRESH_TOKEN_IN_BODY = as_bool(os.environ.get('REFRESH_TOKEN_IN_BODY'))
RESET_TOKEN_MINUTES = int(os.environ.get('RESET_TOKEN_MINUTES') or '15')
PASSWORD_RESET_URL = os.environ.get('PASSWORD_RESET_URL') or \
'http://localhost:3000/reset'
USE_CORS = as_bool(os.environ.get('USE_CORS') or 'yes')
CORS_SUPPORTS_CREDENTIALS = True
# API documentation
APIFAIRY_TITLE = 'Microblog API'
APIFAIRY_VERSION = '1.0'
APIFAIRY_UI = os.environ.get('DOCS_UI', 'elements')
# email options
MAIL_SERVER = os.environ.get('MAIL_SERVER', 'localhost')
MAIL_PORT = int(os.environ.get('MAIL_PORT') or '25')
MAIL_USE_TLS = as_bool(os.environ.get('MAIL_USE_TLS'))
MAIL_USERNAME = os.environ.get('MAIL_USERNAME')
MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
MAIL_DEFAULT_SENDER=os.environ.get('MAIL_DEFAULT_SENDER',