1#! /usr/bin/env python3
3""" Main script to run the dakweb server and also
4to provide the list_paths and path_help functions
6@contact: Debian FTPMaster <ftpmaster@debian.org>
7@copyright: 2014 Mark Hymers <mhy@debian.org>
8@license: GNU General Public License version 2 or later
9"""
11import bottle
12from bottle import redirect
13from daklib.dbconn import DBConn
14import json
16from dakweb.webregister import QueryRegister
19@bottle.route('/')
20def root_path():
21 """Returns a useless welcome message"""
22 return json.dumps('Use the /list_paths path to list all available paths')
25QueryRegister().register_path('/', root_path)
28@bottle.route('/list_paths')
29def list_paths():
30 """Returns a list of available paths"""
31 redirect("https://ftp-team.pages.debian.net/dak/epydoc/dakweb-module.html#__package__")
34QueryRegister().register_path('/list_paths', list_paths)
37@bottle.route('/path_help/<path>')
38def path_help(path=None):
39 """Redirects to the API description containing the path_help"""
40 if path is None:
41 return bottle.HTTPError(503, 'Path not specified.')
43 redirect("https://ftp-team.pages.debian.net/dak/epydoc/%s-module.html#%s" %
44 (QueryRegister().get_path_help(path), path))
47QueryRegister().register_path('/path_help', list_paths)
49# Import our other methods
50from .queries.archive import *
51from .queries.madison import *
52from .queries.source import *
53from .queries.suite import *
54from .queries.binary import *
56# Run the bottle if we're called directly
57if __name__ == '__main__':
58 # Set up our initial database connection
59 d = DBConn()
60 bottle.run()