2020-06-02 21:54:47 +03:00
|
|
|
from app.utils.misc import generate_user_keys
|
2020-01-21 23:26:49 +03:00
|
|
|
from flask import Flask
|
2020-06-02 21:54:47 +03:00
|
|
|
from flask_session import Session
|
2020-01-21 23:26:49 +03:00
|
|
|
import os
|
|
|
|
|
|
|
|
app = Flask(__name__, static_folder=os.path.dirname(os.path.abspath(__file__)) + '/static')
|
2020-06-02 21:54:47 +03:00
|
|
|
app.user_elements = {}
|
2020-06-06 00:24:44 +03:00
|
|
|
app.default_key_set = generate_user_keys()
|
|
|
|
app.no_cookie_ips = []
|
|
|
|
app.config['SECRET_KEY'] = os.urandom(32)
|
2020-06-02 21:54:47 +03:00
|
|
|
app.config['SESSION_TYPE'] = 'filesystem'
|
|
|
|
app.config['VERSION_NUMBER'] = '0.2.0'
|
2020-05-20 20:02:30 +03:00
|
|
|
app.config['APP_ROOT'] = os.getenv('APP_ROOT', os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
app.config['STATIC_FOLDER'] = os.getenv('STATIC_FOLDER', os.path.join(app.config['APP_ROOT'], 'static'))
|
2020-06-06 00:24:44 +03:00
|
|
|
app.config['CONFIG_PATH'] = os.getenv('CONFIG_VOLUME', os.path.join(app.config['STATIC_FOLDER'], 'config'))
|
|
|
|
app.config['DEFAULT_CONFIG'] = os.path.join(app.config['CONFIG_PATH'], 'config.json')
|
|
|
|
app.config['SESSION_FILE_DIR'] = os.path.join(app.config['CONFIG_PATH'], 'session')
|
|
|
|
app.config['SESSION_COOKIE_SAMESITE'] = 'Strict'
|
2020-06-02 21:54:47 +03:00
|
|
|
|
|
|
|
if not os.path.exists(app.config['CONFIG_PATH']):
|
|
|
|
os.makedirs(app.config['CONFIG_PATH'])
|
|
|
|
|
2020-06-06 00:24:44 +03:00
|
|
|
if not os.path.exists(app.config['SESSION_FILE_DIR']):
|
|
|
|
os.makedirs(app.config['SESSION_FILE_DIR'])
|
2020-06-02 23:38:29 +03:00
|
|
|
|
2020-06-06 00:24:44 +03:00
|
|
|
Session(app)
|
2020-01-21 23:26:49 +03:00
|
|
|
|
|
|
|
from app import routes
|