distribusi-verse/verse/app.py

48 lines
1.3 KiB
Python
Raw Normal View History

import os
2022-01-05 13:42:24 +01:00
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_bcrypt import Bcrypt
from flask_migrate import Migrate
from flask_wtf.csrf import CSRFProtect
from flask_login import (
LoginManager,
)
db = SQLAlchemy()
migrate = Migrate()
bcrypt = Bcrypt()
login_manager = LoginManager()
def create_app():
APP = Flask(__name__, static_folder="static")
2022-02-13 23:06:16 +01:00
APP.secret_key = "secret-key"
APP.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///data/distribusiverse.db"
APP.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True
APP.config["MAX_CONTENT_LENGTH"] = 150 * 1024 * 1024
2022-01-05 13:42:24 +01:00
2022-04-03 09:32:17 +02:00
APP.config["MAIL_SERVER"] = "mail.autonomic.zone"
APP.config["MAIL_PORT"] = 587
APP.config["MAIL_USE_SSL"] = False
APP.config["MAIL_USE_TLS"] = True
2022-04-03 09:32:17 +02:00
APP.config['MAIL_USERNAME'] = "noreply@vvvvvvaria.org"
2022-01-05 13:42:24 +01:00
login_manager.session_protection = "strong"
2022-01-05 15:10:18 +01:00
login_manager.login_view = "index"
2022-01-05 13:42:24 +01:00
login_manager.login_message_category = "info"
csrf = CSRFProtect()
2022-02-13 23:06:16 +01:00
APP.config["SECRET_KEY"] = os.urandom(24)
APP.config["UPLOAD_FOLDER"] = "tmpupload"
2022-03-27 12:46:08 +02:00
APP.config["PUBLIC_THEMES"] = "themes/publicthemes"
2022-01-05 13:42:24 +01:00
csrf.init_app(APP)
login_manager.init_app(APP)
db.init_app(APP)
2022-03-27 16:07:44 +02:00
migrate.init_app(APP, db, render_as_batch=True)
2022-01-05 13:42:24 +01:00
bcrypt.init_app(APP)
return APP