major rework
using influxdb structure independed of nicos cache
This commit is contained in:
35
webserver.py
35
webserver.py
@ -165,8 +165,13 @@ def reply():
|
||||
logging.error('%s', traceback.format_exc())
|
||||
circularlog.log()
|
||||
msg = dict(type='error', request=path[1:], error=repr(e))
|
||||
logging.info('REPLY %s %r', path, msg)
|
||||
resp = flask.Response(json.dumps(msg), mimetype='application/json')
|
||||
jsonmsg = json.dumps(msg)
|
||||
if len(jsonmsg) < 120:
|
||||
logging.info('REPLY %s %s', path, jsonmsg)
|
||||
else:
|
||||
logging.info('REPLY %s %s...', path, jsonmsg[:80])
|
||||
logging.debug('REPLY %s %r', path, jsonmsg)
|
||||
resp = flask.Response(jsonmsg, mimetype='application/json')
|
||||
resp.headers['Access-Control-Allow-Origin'] = '*'
|
||||
return resp
|
||||
|
||||
@ -206,10 +211,34 @@ def replace_by_empty(file):
|
||||
|
||||
|
||||
@app.route('/')
|
||||
def default():
|
||||
def main():
|
||||
return general_file('SEAWebClient.html')
|
||||
|
||||
|
||||
@app.route('/select')
|
||||
def default():
|
||||
out = ['''<html><body><table>
|
||||
<style>
|
||||
th {
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
<tr><th>Instrument</th><th colspan=99>Devices</th></tr>''']
|
||||
result = {}
|
||||
for stream, tags in instrument.get_stream_tags().items():
|
||||
ins = tags.get('instrument', '0')
|
||||
result.setdefault(ins, []).append((stream, tags.get('device')))
|
||||
bare_streams = result.pop('0', [])
|
||||
for ins, streams in result.items():
|
||||
out.append(f'<tr><td><a href="/?ins={ins}">{ins}</a></td>')
|
||||
out.extend(f'<td>{d or s}</td>' for s, d in streams)
|
||||
out.append('</tr>')
|
||||
for stream, device in bare_streams:
|
||||
out.append(f'<tr><td><a href="/?srv={stream}">{stream}</a></td><td>{device}</td><tr>')
|
||||
out.extend(['</table></body?</html>', ''])
|
||||
return '\n'.join(out)
|
||||
|
||||
|
||||
@app.route('/<file>')
|
||||
def general_file(file):
|
||||
subdir = "client/"
|
||||
|
Reference in New Issue
Block a user