]> git.decadent.org.uk Git - dak.git/blob - dakweb/dakwebserver.py
Make release_team_removals.sh take input from stdin
[dak.git] / dakweb / dakwebserver.py
1 #!/usr/bin/python
2
3 """ Main script to run the dakweb server and also
4 to provide the list_paths and path_help functions
5
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 """
10
11 import bottle
12 from bottle import redirect
13 from daklib.dbconn import DBConn
14 import json
15
16 from dakweb.webregister import QueryRegister
17
18
19 @bottle.route('/')
20 def root_path():
21     """Returns a useless welcome message"""
22     return json.dumps('Use the /list_paths path to list all available paths')
23 QueryRegister().register_path('/', root_path)
24
25
26 @bottle.route('/list_paths')
27 def list_paths():
28     """Returns a list of available paths"""
29     redirect("https://ftp-master.debian.org/epydoc/dakweb-module.html#__package__")
30 QueryRegister().register_path('/list_paths', list_paths)
31
32
33 @bottle.route('/path_help/<path>')
34 def path_help(path=None):
35     """Redirects to the API description containing the path_help"""
36     if path is None:
37         return bottle.HTTPError(503, 'Path not specified.')
38
39     redirect("https://ftp-master.debian.org/epydoc/%s-module.html#%s" %
40              (QueryRegister().get_path_help(path), path))
41 QueryRegister().register_path('/path_help', list_paths)
42
43 # Import our other methods
44 from queries.archive import *
45 from queries.madison import *
46 from queries.source import *
47 from queries.suite import *
48
49 # Set up our initial database connection
50 d = DBConn()
51
52 # Run the bottle if we're called directly
53 if __name__ == '__main__':
54     bottle.run()