]> git.ipfire.org Git - people/ms/westferry.git/blame - src/westferry/application.py
Add handler that serves graphs from collecty
[people/ms/westferry.git] / src / westferry / application.py
CommitLineData
9877dda9
MT
1#!/usr/bin/python3
2###############################################################################
3# #
4# Westferry - The IPFire web user interface #
5# Copyright (C) 2015 IPFire development team #
6# #
7# This program is free software: you can redistribute it and/or modify #
8# it under the terms of the GNU General Public License as published by #
9# the Free Software Foundation, either version 3 of the License, or #
10# (at your option) any later version. #
11# #
12# This program is distributed in the hope that it will be useful, #
13# but WITHOUT ANY WARRANTY; without even the implied warranty of #
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15# GNU General Public License for more details. #
16# #
17# You should have received a copy of the GNU General Public License #
18# along with this program. If not, see <http://www.gnu.org/licenses/>. #
19# #
20###############################################################################
21
22import tornado.web
23
21a66327 24from . import backend
9877dda9
MT
25from . import handlers
26from . import ui
27
b0645c6e
MT
28from .constants import *
29
9877dda9
MT
30class WebApplication(tornado.web.Application):
31 def __init__(self, **kwargs):
32 settings = {
33 # Enable compressed output
34 "compress_response" : True,
35
b0645c6e
MT
36 # Serve static files from our webroot
37 "static_path" : WEBROOTDIR,
38
95da2e86
MT
39 # Templates
40 "template_path" : TEMPLATESDIR,
41
9877dda9
MT
42 # Use Cross-Site-Request-Forgery protection
43 "xsrf_cookies" : True,
44 }
45 settings.update(kwargs)
46
47 # Get handlers
48 h = [(h.url, h) for h in handlers.get_handlers()]
49
50 # Get UI modules and methods
51 settings.update({
52 "ui_methods" : ui.get_ui_methods(),
53 "ui_modules" : ui.get_ui_modules(),
54 })
55
56 # Initialise the web application
57 tornado.web.Application.__init__(self, handlers=h, **settings)
21a66327
MT
58
59 @property
60 def backend(self):
61 if not hasattr(self, "_backend"):
62 self._backend = backend.Backend()
63
64 return self._backend