From 410958a2a79a448626dc76c66c53d3aa639544b1 Mon Sep 17 00:00:00 2001 From: Disassembler Date: Wed, 31 Oct 2018 16:42:45 +0100 Subject: [PATCH] Simplify compile_url --- basic/srv/vm/mgr/tools.py | 3 +-- basic/srv/vm/mgr/wsgiapp.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/basic/srv/vm/mgr/tools.py b/basic/srv/vm/mgr/tools.py index d697fb2..1c0e4fd 100644 --- a/basic/srv/vm/mgr/tools.py +++ b/basic/srv/vm/mgr/tools.py @@ -15,8 +15,7 @@ from cryptography.x509.oid import NameOID def compile_url(domain, port, proto='https'): port = '' if (proto == 'https' and port == '443') or (proto == 'http' and port == '80') else ':{}'.format(port) - host = '{}{}'.format(domain, port) - return '{}://{}'.format(proto, host) if proto is not None else host + return '{}://{}{}'.format(proto, domain, port) def get_local_ipv4(): # Return first routable IPv4 address of the VM (container host) diff --git a/basic/srv/vm/mgr/wsgiapp.py b/basic/srv/vm/mgr/wsgiapp.py index 6480868..f39fca1 100644 --- a/basic/srv/vm/mgr/wsgiapp.py +++ b/basic/srv/vm/mgr/wsgiapp.py @@ -131,7 +131,7 @@ class WSGIApp(object): self.conf.save() # Redirect to host setup view return redirect('/setup-host') - host = tools.compile_url(self.conf['host']['domain'], self.conf['host']['port'], None) + host = tools.compile_url(self.conf['host']['domain'], self.conf['host']['port'])[8:] if request.session['admin']: return self.render_template('portal-admin.html', request, host=host) return self.render_template('portal-user.html', request, host=host)