Files
@ e9e85b209c6f
Branch filter:
Location: FVDE/ennstatus/ennstatus/__init__.py
e9e85b209c6f
2.8 KiB
text/x-python
Use rt instead of rtkit
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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | # Ënnstatus
# Copyright (C) 2015 Dennis Fink
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os.path
import json
from flask import Flask, render_template
from flask.ext.bootstrap import Bootstrap
from flask.ext.wtf import CsrfProtect
from flask.ext.moment import Moment
from werkzeug.contrib.fixers import ProxyFix
import gnupg
bootstrap = Bootstrap()
csrf = CsrfProtect()
moment = Moment()
config_file = os.path.abspath('config.json')
def create_app():
app = Flask(__name__)
import ennstatus.config as config
config.init_app(app)
if not hasattr(app.config, 'from_json'):
def from_json(file, silent=True):
try:
with open(file, encoding='utf-8') as json_file:
obj = json.load(json_file)
except IOError:
if silent:
return False
raise
for key in obj:
if key.isupper():
app.config[key] = obj[key]
return True
app.config.from_json = from_json
app.config.from_json(config_file)
app.wsgi_app = ProxyFix(app.wsgi_app)
bootstrap.init_app(app)
csrf.init_app(app)
moment.init_app(app)
from .status.functions import mail
mail.init_app(app)
from .root.views import root_page
app.register_blueprint(root_page)
from .api.views import api_page
app.register_blueprint(api_page, url_prefix='/api')
from .donate.views import donate_page
app.register_blueprint(donate_page, url_prefix='/donate')
from .status.views import status_page
app.register_blueprint(status_page, url_prefix='/status')
from .statistics.views import statistics_page
app.register_blueprint(statistics_page, url_prefix='/statistics')
from .data.views import data_page
app.register_blueprint(data_page, url_prefix='/data')
from .log import init_logging
init_logging(app)
if 'ENNSTATUS_GPG_HOME' in app.config:
gpg = gnupg.GPG(gnupghome=app.config['ENNSTATUS_GPG_HOME'])
gpg.encoding = 'utf-8'
app.extensions['gnupg'] = gpg
else:
app.extensions['gnupg'] = False
@app.errorhandler(404)
def page_not_found(e):
return render_template('errorpages/404.html')
return app
|