blob: 89efa7756043460f405c259d43f3725b3dc20840 [file] [log] [blame]
genia.likes.science@gmail.com67605862013-10-04 05:43:57 -07001import admaql101
2import requests
3from bottle import route, run, template, get, debug, static_file, request, response
4
5debug(True)
6http_header = { "content-type": "application/json" }
7
8# Core Routing
9@route('/')
10def jsontest():
11 return template('demo')
12
13@route('/static/<filename:path>')
14def send_static(filename):
15 return static_file(filename, root='static')
16
17# API Helpers
18def build_response(endpoint, data):
19 api_endpoint = "http://localhost:19002/" + endpoint
20 response = requests.get(api_endpoint, params=data, headers=http_header)
21 try:
22 return response.json();
23 except ValueError:
24 return []
25
26# API Endpoints
27@route('/query')
28def run_asterix_query():
29 return (build_response("query", dict(request.query)))
30
31@route('/query/status')
32def run_asterix_query_status():
33 return (build_response("query/status", dict(request.query)))
34
35@route('/query/result')
36def run_asterix_query_result():
37 return (build_response("query/result", dict(request.query)))
38
39
40@route('/ddl')
41def run_asterix_ddl():
42 return (build_response("ddl", dict(request.query)))
43
44@route('/update')
45def run_asterix_update():
46 return (build_response("update", dict(request.query)))
47
48res = admaql101.bootstrap()
49run(host='localhost', port=8081, debug=True)