]>
Commit | Line | Data |
---|---|---|
e5424f29 MR |
1 | #!flask/bin/python |
2 | from app import app | |
fc01a3eb MR |
3 | from config import ADMINS, MAIL_SERVER, MAIL_PORT, MAIL_USERNAME, MAIL_PASSWORD |
4 | import logging | |
5 | ||
6 | app.debug = True | |
7 | ||
8 | if not app.debug: | |
9 | from logging.handlers import SMTPHandler, RotatingFileHandler | |
10 | credentials = None | |
11 | if MAIL_USERNAME or MAIL_PASSWORD: | |
12 | credentials = (MAIL_USERNAME, MAIL_PASSWORD) | |
13 | mail_handler = SMTPHandler((MAIL_SERVER, MAIL_PORT), 'no-reply@' + MAIL_SERVER, ADMINS, 'PWP failure', credentials) | |
14 | mail_handler.setLevel(logging.ERROR) | |
15 | mail_handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]')) | |
16 | app.logger.addHandler(mail_handler) | |
17 | ||
18 | file_handler = RotatingFileHandler('log/pwp.log', 'a', 1 * 1024 * 1024, 10) | |
19 | file_handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]')) | |
20 | app.logger.addHandler(file_handler) | |
21 | file_handler.setLevel(logging.DEBUG) | |
22 | else: | |
23 | # from flask_debugtoolbar import DebugToolbarExtension | |
24 | ||
25 | # toolbar = DebugToolbarExtension(app) | |
26 | app.jinja_env.auto_reload = True | |
27 | app.config['TEMPLATES_AUTO_RELOAD'] = True | |
28 | ||
29 | app.logger.setLevel(logging.DEBUG) | |
30 | app.logger.info('pwp startup') | |
31 | #from werkzeug.security import generate_password_hash | |
32 | #print (generate_password_hash('test', method='sha256')) | |
33 | app.run() |