mirror of
https://github.com/rembo10/headphones.git
synced 2026-05-19 18:15:31 +01:00
Added http_root option
This commit is contained in:
@@ -9,6 +9,11 @@ http_host = General['http_host']
|
||||
http_port = General['http_port']
|
||||
http_username = General['http_username']
|
||||
http_password = General['http_password']
|
||||
try:
|
||||
http_root = General['http_root']
|
||||
except KeyError:
|
||||
General['http_root'] = ''
|
||||
config.write()
|
||||
launch_browser = General['launch_browser']
|
||||
usenet_retention = General['usenet_retention']
|
||||
include_lossless = General['include_lossless']
|
||||
|
||||
@@ -8,6 +8,7 @@ def configCreate(path):
|
||||
config['General']['http_port'] = 8181
|
||||
config['General']['http_username'] = ''
|
||||
config['General']['http_password'] = ''
|
||||
config['General']['http_root'] = ''
|
||||
config['General']['launch_browser'] = 1
|
||||
config['General']['include_lossless'] = 0
|
||||
config['General']['flac_to_mp3'] = 0
|
||||
|
||||
@@ -86,6 +86,9 @@ h1{
|
||||
.smalltext{
|
||||
font-size: 11px;
|
||||
}
|
||||
.bigtext{
|
||||
font-size: 22px;
|
||||
}
|
||||
a:link {
|
||||
color: #5E2612;
|
||||
text-decoration: none;
|
||||
|
||||
@@ -20,6 +20,7 @@ FULL_PATH = os.path.dirname(os.path.abspath(__file__))
|
||||
config_file = os.path.join(FULL_PATH, 'config.ini')
|
||||
LOG_DIR = os.path.join(FULL_PATH, 'logs')
|
||||
|
||||
web_root = None
|
||||
|
||||
if os.path.exists(config_file):
|
||||
pass
|
||||
@@ -105,20 +106,28 @@ def serverstart():
|
||||
|
||||
logger.sb_log_instance.initLogging(consoleLogging=consoleLogging)
|
||||
|
||||
|
||||
global web_root
|
||||
try:
|
||||
web_root = settings['http_root']
|
||||
except KeyError:
|
||||
web_root = '/'
|
||||
|
||||
def browser():
|
||||
if settings['http_host'] == '0.0.0.0':
|
||||
host = 'localhost'
|
||||
else:
|
||||
host = settings['http_host']
|
||||
webbrowser.open('http://' + host + ':' + settings['http_port'])
|
||||
webbrowser.open('http://' + host + ':' + settings['http_port'] + web_root)
|
||||
|
||||
|
||||
if settings['launch_browser'] == '1':
|
||||
cherrypy.engine.subscribe('start', browser, priority=90)
|
||||
|
||||
logger.log(u"Starting Headphones on port:" + settings['http_port'])
|
||||
cherrypy.quickstart(webServer.Headphones(), config = conf)
|
||||
|
||||
|
||||
|
||||
cherrypy.quickstart(webServer.Headphones(), web_root, config = conf)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -241,7 +241,7 @@ class WebService(IWebService):
|
||||
query = urllib.urlencode(params)
|
||||
|
||||
url = urlparse.urlunparse(('http', netloc, path, '', query,''))
|
||||
|
||||
|
||||
return url
|
||||
|
||||
|
||||
|
||||
12
webServer.py
12
webServer.py
@@ -163,19 +163,19 @@ class Headphones:
|
||||
artistResults = ws.Query().getArtists(ws.ArtistFilter(string.replace(name, '&', '%38'), limit=8))
|
||||
if len(artistResults) == 0:
|
||||
logger.log(u"No results found for " + name)
|
||||
page.append('''No results!<a class="blue" href="/">Go back</a>''')
|
||||
page.append('''No results!<a class="blue" href="">Go back</a>''')
|
||||
return page
|
||||
elif len(artistResults) > 1:
|
||||
page.append('''Search returned multiple artists. Click the artist you want to add:<br /><br />''')
|
||||
for result in artistResults:
|
||||
artist = result.artist
|
||||
page.append('''<a href="/addArtist?artistid=%s">%s</a> (<a class="externalred" href="/artistInfo?artistid=%s">more info</a>)<br />''' % (u.extractUuid(artist.id), artist.name, u.extractUuid(artist.id)))
|
||||
page.append('''<a href="addArtist?artistid=%s">%s</a> (<a class="externalred" href="/artistInfo?artistid=%s">more info</a>)<br />''' % (u.extractUuid(artist.id), artist.name, u.extractUuid(artist.id)))
|
||||
return page
|
||||
else:
|
||||
for result in artistResults:
|
||||
artist = result.artist
|
||||
logger.log(u"Found one artist matching your search term: " + artist.name +" ("+ artist.id+")")
|
||||
raise cherrypy.HTTPRedirect("/addArtist?artistid=%s" % u.extractUuid(artist.id))
|
||||
raise cherrypy.HTTPRedirect("addArtist?artistid=%s" % u.extractUuid(artist.id))
|
||||
|
||||
findArtist.exposed = True
|
||||
|
||||
@@ -200,7 +200,7 @@ class Headphones:
|
||||
artistlist = c.fetchall()
|
||||
if any(artistid in x for x in artistlist):
|
||||
page = [templates._header]
|
||||
page.append('''%s has already been added. Go <a href="/">back</a>.''' % artist.name)
|
||||
page.append('''%s has already been added. Go <a href="">back</a>.''' % artist.name)
|
||||
logger.log(artist.name + u" is already in the database!", logger.WARNING)
|
||||
c.close()
|
||||
return page
|
||||
@@ -334,7 +334,9 @@ class Headphones:
|
||||
''' % (albumart, albums[i][6], albums[i][5], albums[i][4], albums[i][0], albums[i][1]))
|
||||
i += 1
|
||||
page.append('''</table></div>''')
|
||||
page.append(templates._footer)
|
||||
if len(albums):
|
||||
page.append(templates._footer)
|
||||
|
||||
return page
|
||||
upcoming.exposed = True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user