blob: 8c8df9b1cda3115888a2fe90813d5b0a360e91eb [file] [log] [blame]
genia.likes.science@gmail.comd42b4022013-08-09 05:05:23 -07001import black_cherry_bootstrap
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('cherry')
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 return response.json()
22
23# API Endpoints
24@route('/query')
25def run_asterix_query():
26 return (build_response("query", dict(request.query)))
27
28@route('/query/status')
29def run_asterix_query_status():
30 return (build_response("query/status", dict(request.query)))
31
32@route('/query/result')
33def run_asterix_query_result():
34 return (build_response("query/result", dict(request.query)))
35
36
37@route('/ddl')
38def run_asterix_ddl():
39 return (build_response("ddl", dict(request.query)))
40
41@route('/update')
42def run_asterix_update():
43 return (build_response("update", dict(request.query)))
44
45res = black_cherry_bootstrap.bootstrap()
46run(host='localhost', port=8080, reloader=True)