mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-22 17:06:17 +00:00
Adding a way to disable some features. First one: the frontend
This commit is contained in:
parent
4ce3958cbb
commit
72f8e6b52c
10
config.py
10
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
|
||||
|
||||
|
51
templates/no-frontend.html
Normal file
51
templates/no-frontend.html
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
-#}
|
||||
<!DOCTYPE html>
|
||||
<title>Supysonic</title>
|
||||
<style>
|
||||
/* Sticky footer method from http://www.cssstickyfooter.com/ */
|
||||
html, body { height: 100%; }
|
||||
#wrap { min-height: 100%; }
|
||||
#main {
|
||||
overflow: auto;
|
||||
padding-bottom: 3em;
|
||||
}
|
||||
#footer {
|
||||
position: relative;
|
||||
margin-top: -3em;
|
||||
height: 3em;
|
||||
clear: both;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
/* Opera fix */
|
||||
body:before {
|
||||
content: "";
|
||||
height: 100%;
|
||||
float: left;
|
||||
width: 0;
|
||||
margin-top: -32767px;
|
||||
}
|
||||
</style>
|
||||
<div id="wrap"><div id="main">
|
||||
<h1>Supysonic</h1>
|
||||
<p>This interface has been disabled, there's nothing to see here.</p>
|
||||
</div></div>
|
||||
<div id="footer">Supysonic <a href="https://github.com/spl0k/supysonic">source code</a> is available under the <a href="http://www.gnu.org/licenses/agpl-3.0.html">GNU Affero General Public License version 3</a>.</div>
|
||||
|
11
web.py
11
web.py
@ -19,13 +19,16 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user