site/backend/app/__init__.py

41 lines
1.3 KiB
Python
Raw Normal View History

2024-08-01 06:56:27 +00:00
from flask import Flask
2024-08-01 10:33:45 +00:00
from config import Config
2024-08-01 13:35:28 +00:00
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
2024-08-01 18:10:49 +00:00
from flask_login import LoginManager
2024-08-03 18:45:37 +00:00
import logging, sys
2024-08-03 15:58:32 +00:00
from logging.handlers import SMTPHandler
2024-08-05 05:00:07 +00:00
from flask_mail import Mail
2024-08-01 06:56:27 +00:00
app = Flask(__name__)
2024-08-01 10:33:45 +00:00
app.config.from_object(Config)
2024-08-01 13:35:28 +00:00
db = SQLAlchemy(app)
migrate = Migrate(app, db)
2024-08-01 18:10:49 +00:00
login = LoginManager(app)
login.login_view = 'login'
2024-08-05 05:00:07 +00:00
mail=Mail(app)
2024-08-01 06:56:27 +00:00
2024-08-03 18:45:37 +00:00
if not app.debug:
if app.config['MAIL_SERVER']:
auth = None
secure = None
mail_handler = SMTPHandler(
mailhost=(app.config['MAIL_SERVER'], app.config['MAIL_PORT']),
fromaddr=app.config['FROM_ADDRESS'],
toaddrs=app.config['ADMINS'], subject='MB failure.',
credentials=auth, secure=secure)
mail_handler.setLevel(logging.ERROR)
app.logger.addHandler(mail_handler)
if app.config['DC_LOGGING']:
2024-08-04 11:39:49 +00:00
print('#################### TEST PRINT STDERR DEBUG', file=sys.stderr)
2024-08-03 18:45:37 +00:00
dclog = logging.StreamHandler(stream=sys.stderr)
dclog.setLevel(logging.INFO)
dclog.propagate = False
app.logger.addHandler(dclog)
2024-08-04 11:39:49 +00:00
app.logger.info('@@@@@@@@@@@@@@@@@@@@@ TEST LOGGER INFO MESSAGE')
2024-08-03 18:45:37 +00:00
2024-08-03 13:31:19 +00:00
from app import routes, models, errors
2024-08-01 06:56:27 +00:00