#!/usr/bin/python

""" Main script to run the licweb server and also
to provide the list_paths and path_help functions

@contact: Thorsten Alteholz <thorsten@alteholz.eu>
@copyright: 2014  Mark Hymers <mhy@debian.org>
@copyright: 2017 Thorsten Alteholz <thorsten@alteholz.eu>
@license: GNU General Public License version 2 or later
"""

import bottle
from bottle import redirect
import json

from webregister import QueryRegister

@bottle.route('/')
def root_path():
    """Returns a useless welcome message"""
#    return json.dumps('Use the /list_paths path to list all available paths')
    redirect("http://licapi.debian.net/template")
QueryRegister().register_path('/', root_path)


#@bottle.route('/list_paths')
#def list_paths():
#    """Returns a list of available paths"""
#    redirect("https://license.api.alteholz.net/html/licwebserver-module.html#__package__")
#QueryRegister().register_path('/list_paths', list_paths)


#@bottle.route('/path_help/<path>')
#def path_help(path=None):
#    """Redirects to the API description containing the path_help"""
#    if path is None:
#        return bottle.HTTPError(503, 'Path not specified.')
#
#    redirect("https:/license.api.alteholz.net/html/%s-module.html#%s" %
#             (QueryRegister().get_path_help(path), path))
#QueryRegister().register_path('/path_help', list_paths)

# Import our other methods
###from queries.archive import *
###from queries.madison import *
###from queries.source import *
###from queries.suite import *
from queries.template import *

# Run the bottle if we're called directly
if __name__ == '__main__':
    bottle.run()

