blob: 1e060b76384571ced0177022ac29dcfc7880a9a3 [file] [log] [blame]
Till Westmann5b431ca2015-10-01 19:16:11 -07001# Licensed to the Apache Software Foundation (ASF) under one
2# or more contributor license agreements. See the NOTICE file
3# distributed with this work for additional information
4# regarding copyright ownership. The ASF licenses this file
5# to you under the Apache License, Version 2.0 (the
6# "License"); you may not use this file except in compliance
7# with the License. You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing,
12# software distributed under the License is distributed on an
13# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14# KIND, either express or implied. See the License for the
15# specific language governing permissions and limitations
16# under the License.
17
genia.likes.science@gmail.com67605862013-10-04 05:43:57 -070018import admaql101
19import requests
20from bottle import route, run, template, get, debug, static_file, request, response
21
22debug(True)
23http_header = { "content-type": "application/json" }
24
25# Core Routing
26@route('/')
27def jsontest():
28 return template('demo')
29
30@route('/static/<filename:path>')
31def send_static(filename):
32 return static_file(filename, root='static')
33
34# API Helpers
35def build_response(endpoint, data):
36 api_endpoint = "http://localhost:19002/" + endpoint
37 response = requests.get(api_endpoint, params=data, headers=http_header)
38 try:
39 return response.json();
40 except ValueError:
41 return []
42
43# API Endpoints
44@route('/query')
45def run_asterix_query():
46 return (build_response("query", dict(request.query)))
47
48@route('/query/status')
49def run_asterix_query_status():
50 return (build_response("query/status", dict(request.query)))
51
52@route('/query/result')
53def run_asterix_query_result():
54 return (build_response("query/result", dict(request.query)))
55
56
57@route('/ddl')
58def run_asterix_ddl():
59 return (build_response("ddl", dict(request.query)))
60
61@route('/update')
62def run_asterix_update():
63 return (build_response("update", dict(request.query)))
64
65res = admaql101.bootstrap()
66run(host='localhost', port=8081, debug=True)