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