Simplify compile_url

This commit is contained in:
Disassembler 2018-10-31 16:42:45 +01:00
parent 76220d811d
commit 410958a2a7
Signed by: Disassembler
GPG Key ID: 524BD33A0EE29499
2 changed files with 2 additions and 3 deletions

View File

@ -15,8 +15,7 @@ from cryptography.x509.oid import NameOID
def compile_url(domain, port, proto='https'): def compile_url(domain, port, proto='https'):
port = '' if (proto == 'https' and port == '443') or (proto == 'http' and port == '80') else ':{}'.format(port) port = '' if (proto == 'https' and port == '443') or (proto == 'http' and port == '80') else ':{}'.format(port)
host = '{}{}'.format(domain, port) return '{}://{}{}'.format(proto, domain, port)
return '{}://{}'.format(proto, host) if proto is not None else host
def get_local_ipv4(): def get_local_ipv4():
# Return first routable IPv4 address of the VM (container host) # Return first routable IPv4 address of the VM (container host)

View File

@ -131,7 +131,7 @@ class WSGIApp(object):
self.conf.save() self.conf.save()
# Redirect to host setup view # Redirect to host setup view
return redirect('/setup-host') 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']: if request.session['admin']:
return self.render_template('portal-admin.html', request, host=host) return self.render_template('portal-admin.html', request, host=host)
return self.render_template('portal-user.html', request, host=host) return self.render_template('portal-user.html', request, host=host)