]> git.donarmstrong.com Git - dak.git/blob - dakweb/dakwebserver.py
Add initial suites and archives routines
[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 from sqlalchemy import or_
7 import bottle
8 from daklib.dbconn import DBConn, DBSource, Suite, DSCFile, PoolFile
9 import json
10
11 from dakweb.webregister import QueryRegister
12
13 @bottle.route('/')
14 def root_path():
15     """Returns a useless welcome message"""
16     return json.dumps('Use the /list_paths path to list all available paths')
17 QueryRegister().register_path('/', root_path)
18
19 @bottle.route('/list_paths')
20 def list_paths():
21     """Returns a list of available paths"""
22     return json.dumps(QueryRegister().get_paths())
23 QueryRegister().register_path('/list_paths', list_paths)
24
25 @bottle.route('/path_help/<path>')
26 def path_help(path=None):
27
28     if path is None:
29         return bottle.HTTPError(503, 'Path not specified.')
30
31     return json.dumps(QueryRegister().get_path_help(path))
32 QueryRegister().register_path('/path_help', list_paths)
33
34 # Import our other methods
35 from queries.archive import *
36 from queries.source import *
37 from queries.suite import *
38
39 # Set up our initial database connection
40 d = DBConn()
41
42 # Run the bottle if we're called directly
43 if __name__ == '__main__':
44     bottle.run()