forked from byu-osl/citizen-budget
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
67 lines (48 loc) · 1.76 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from flask import redirect, session, url_for
### Configuration ###
from config import app
### Custom Filters ###
def currency(value):
return "{:,.2f}".format(value)
app.jinja_env.filters['currency'] = currency
### Handlers ###
from views.index import index
app.register_blueprint(index)
from views.year import year
app.register_blueprint(year, url_prefix="/year")
from views.trend import trend
app.register_blueprint(trend, url_prefix="/trend")
from views.admin import admin
app.register_blueprint(admin, url_prefix="/admin")
from views.city import city
app.register_blueprint(city, url_prefix="/city")
if __name__ == '__main__':
app.debug = True
app.run(host='0.0.0.0')
else:
import logging
from logging.handlers import SMTPHandler
from logging import Formatter
from config import ADMINS,emailAddress,emailPassword,logFile
from datetime import date
today = date.today().strftime("%d %m %Y")
mail_handler = SMTPHandler(('smtp.gmail.com',587),
emailAddress,
ADMINS, 'Citizen Budget: %s' % today,
credentials=(emailAddress,emailPassword),
secure=())
mail_handler.setLevel(logging.ERROR)
mail_handler.setFormatter(Formatter('''
Message type: %(levelname)s
Location: %(pathname)s:%(lineno)d
Module: %(module)s
Function: %(funcName)s
Time: %(asctime)s
Message:
%(message)s
'''))
app.logger.addHandler(mail_handler)
from logging.handlers import RotatingFileHandler
file_handler = RotatingFileHandler(logFile,maxBytes=10000,backupCount=5)
file_handler.setLevel(logging.WARNING)
app.logger.addHandler(file_handler)