]> git.datanom.net - wpp.git/blame - app/__init__.py
rm test access
[wpp.git] / app / __init__.py
CommitLineData
047d4d29
MR
1from flask import Flask
2from flask_bootstrap import Bootstrap
3from flask_sqlalchemy import SQLAlchemy
4from config import ADMINS, MAIL_SERVER, MAIL_PORT, MAIL_USERNAME, MAIL_PASSWORD
5from flask_login import LoginManager
6
7app = Flask(__name__)
8app.config.from_object('config')
9lm = LoginManager()
10lm.init_app(app)
11lm.login_view = 'login'
12db = SQLAlchemy(app)
13bootstrap = Bootstrap(app)
14
15if not app.debug:
16 import logging
17
18 from logging.handlers import SMTPHandler, RotatingFileHandler
19 credentials = None
20 if MAIL_USERNAME or MAIL_PASSWORD:
21 credentials = (MAIL_USERNAME, MAIL_PASSWORD)
22 mail_handler = SMTPHandler((MAIL_SERVER, MAIL_PORT), 'no-reply@' + MAIL_SERVER, ADMINS, 'WPP failure', credentials)
23 mail_handler.setLevel(logging.ERROR)
24 mail_handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]'))
25 app.logger.addHandler(mail_handler)
26
27 file_handler = RotatingFileHandler('log/wpp.log', 'a', 1 * 1024 * 1024, 10)
28 file_handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]'))
29 app.logger.addHandler(file_handler)
30
31 app.logger.setLevel(logging.INFO)
32 file_handler.setLevel(logging.INFO)
33 app.logger.info('wpp startup')
34
35from app import views, models
This page took 0.05539 seconds and 5 git commands to generate.