From: Philipp Klaus Date: Mon, 25 Sep 2017 03:30:56 +0000 (+0800) Subject: DASH: Use Bottle() instance to define routes X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=779027a18692c477ce66da650326684b44404b1d;p=mvd_epics.git DASH: Use Bottle() instance to define routes --- diff --git a/python_suite/dashboard/dashboard.py b/python_suite/dashboard/dashboard.py index 7184ad2..9e2f25c 100755 --- a/python_suite/dashboard/dashboard.py +++ b/python_suite/dashboard/dashboard.py @@ -4,7 +4,7 @@ import json, threading, time, copy, math import simplejson import epics -from bottle import route, run, static_file, redirect, abort, response, HTTPResponse, server_names +from bottle import Bottle, route, run, static_file, redirect, abort, response, HTTPResponse, server_names from bottle import jinja2_view as view CONFIG = None @@ -176,30 +176,32 @@ def json_replace_nan(): # ---------- Bottle routes ---------- -@route('/') +app = Bottle() + +@app.route('/') def index(): redirect('/list_bs/general_overview') -@route('/pv/') +@app.route('/pv/') @view('pv_details_bootstrap.jinja2') def pv_details(pv_name): return {'pv_name': pv_name, 'config': CONFIG} -@route('/list_bs/') +@app.route('/list_bs/') @view('pv_overview_bootstrap.jinja2') def list_pvs_bs(page): if page not in CONFIG['pages']: return abort(404, 'Page not found') return {'config': CONFIG, 'req_page': page} -@route('/list/') +@app.route('/list/') @view('pv_overview.jinja2') def list_pvs(page): if page not in CONFIG['pages']: return abort(404, 'Page not found') return {'config': CONFIG, 'req_page': page} -@route('/gview/') +@app.route('/gview/') @view('gview.jinja2') def gview(name): try: @@ -208,12 +210,12 @@ def gview(name): return abort(404, 'Page not found') return {'config': CONFIG, 'req_page': name, 'svg': svg} -@route('/api/values.json') +@app.route('/api/values.json') @json_replace_nan() def api_values(): return CONFIG -@route('/api/history/.json') +@app.route('/api/history/.json') @json_replace_nan() def api_history(name): try: @@ -235,7 +237,7 @@ def api_history(name): ret_dict.update(pv) return ret_dict -@route('/static/') +@app.route('/static/') def static_content(path): return static_file(path, root='./static/')