feat: Add ssl redirect
All checks were successful
Build Docker / Build Main Image (push) Successful in 18s
Build Docker / Build SLDs Image (push) Successful in 19s

This commit is contained in:
Nathan Woodburn 2023-11-16 13:05:46 +11:00
parent ee435a6e1d
commit e5a0560f2c
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

View File

@ -13,11 +13,18 @@ def render(data,db_object):
# Render as HTML
html = ""
ssl = "<script src='https://nathan.woodburn/https.js'></script>"
if ("localhost" in request.host or "127.0.0.1" in request.host):
ssl = ""
try:
soup = BeautifulSoup(data, 'html.parser')
for script in soup.find_all('script'):
script.extract()
# Inject SSL
soup.append(BeautifulSoup(ssl, 'html.parser'))
html = str(soup)
except Exception as e:
return "<h1>Invalid HTML</h1><br>" + str(e)
@ -66,8 +73,9 @@ def render(data,db_object):
except Exception as e:
return "<h1>Invalid data</h1><br><h2>Please contact support</h2><br><p>This can often be fixed by saving your site again in the editor</p><br>" + "<script>console.log('" + str(e).replace('\'','') + "');</script>"
return render_template('city.html',html=html,bg_colour=bg_colour,text_colour=text_colour,
return render_template('city.html',bg_colour=bg_colour,text_colour=text_colour,
fg_colour=fg_colour, avatar=avatar,main_domain=main_domain,
hnschat=hnschat,email=email,location=location, hns_icon=hns_icon,
hns=hns,btc=btc,eth=eth, data=html)