adjust layout and show ELOG page with relevant procedure
This commit is contained in:
+14
-7
@@ -9,10 +9,15 @@ from flask import Flask, render_template, request, redirect, jsonify
|
||||
app = Flask(__name__)
|
||||
|
||||
class Args:
|
||||
def __init__(self, name, port='8050', webport='8051'):
|
||||
def __init__(self, name, port='', wsport=''):
|
||||
if '.' in name:
|
||||
name, port = name.split('.')
|
||||
webport = str(int(port) + 1)
|
||||
# when called with service argument %i
|
||||
posargs = f'{name}..'.split('.')
|
||||
name, port, wsport = posargs[:3]
|
||||
if not port:
|
||||
port = '8050'
|
||||
if not wsport:
|
||||
wsport = str(int(port) + 1)
|
||||
args = dict(
|
||||
html = 'common.html',
|
||||
svg = 'common.svg',
|
||||
@@ -31,21 +36,23 @@ class Args:
|
||||
if '.' not in hostname:
|
||||
hostname += '.psi.ch'
|
||||
self.hostname = hostname
|
||||
self.webport = webport
|
||||
self.wsport = wsport
|
||||
self.port = int(port)
|
||||
self.html = args.pop('html')
|
||||
args['name'] = name
|
||||
self.args = args
|
||||
|
||||
|
||||
args = Args(*sys.argv[1:])
|
||||
|
||||
print(args)
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
if request.args.get('tunneled'):
|
||||
wsaddr = f'127.0.0.1:{args.webport}'
|
||||
wsaddr = f'127.0.0.1:{args.wsport}'
|
||||
else:
|
||||
wsaddr = f'{args.hostname}:{args.webport}'
|
||||
wsaddr = f'{args.hostname}:{args.wsport}'
|
||||
print(wsaddr, args.port, args.html, args.args)
|
||||
return render_template(f'{args.html}', wsaddr=wsaddr, **args.args)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user