]> git.datanom.net - wpp.git/blob - app/__init__.py
test access
[wpp.git] / app / __init__.py
1 from flask import Flask
2 from flask_bootstrap import Bootstrap
3 from flask_sqlalchemy import SQLAlchemy
4 from config import ADMINS, MAIL_SERVER, MAIL_PORT, MAIL_USERNAME, MAIL_PASSWORD
5 from flask_login import LoginManager
6
7 app = Flask(__name__)
8 app.config.from_object('config')
9 lm = LoginManager()
10 lm.init_app(app)
11 lm.login_view = 'login'
12 db = SQLAlchemy(app)
13 bootstrap = Bootstrap(app)
14
15 if 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
35 from app import views, models
This page took 0.096969 seconds and 6 git commands to generate.