diff --git a/config.py b/config.py index 193252d..3c7a9c6 100644 --- a/config.py +++ b/config.py @@ -41,9 +41,15 @@ def check(): return True -def get(section, name): +def get(section, name, default = None): try: return config.get(section, name) except: - return None + return default + +def getbool(section, name, default = False): + try: + return config.getboolean(section, name) + except: + return default diff --git a/templates/no-frontend.html b/templates/no-frontend.html new file mode 100644 index 0000000..a686483 --- /dev/null +++ b/templates/no-frontend.html @@ -0,0 +1,51 @@ +{#- + This file is part of Supysonic. + + Supysonic is a Python implementation of the Subsonic server API. + Copyright (C) 2013 Alban 'spl0k' FĂ©ron + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +-#} + +Supysonic + +
+

Supysonic

+

This interface has been disabled, there's nothing to see here.

+
+ + diff --git a/web.py b/web.py index 1ce3beb..9f11988 100644 --- a/web.py +++ b/web.py @@ -19,13 +19,16 @@ # along with this program. If not, see . import os.path -from flask import Flask, request, session, flash, render_template, redirect, url_for +from flask import Flask, render_template import config def teardown(exception): db.session.remove() +def disabled_frontend_page(): + return render_template('no-frontend.html') + def create_application(): global app, db, UserManager @@ -50,7 +53,11 @@ def create_application(): app.teardown_request(teardown) - import frontend + if config.getbool('features', 'frontend', True): + import frontend + else: + app.add_url_rule('/', view_func = disabled_frontend_page) + import api return app