from flask import Flask, redirect, render_template_string, request
from bs4 import BeautifulSoup
import os
import dotenv
main_domain = "shakecities.com"
if os.getenv('MAIN_DOMAIN') != None:
main_domain = os.getenv('MAIN_DOMAIN')
FOOTER=""
if os.path.exists("parts/footer.html"):
with open("parts/footer.html") as f:
FOOTER = f.read()
elif os.path.exists("sites/parts/footer.html"):
with open("sites/parts/footer.html") as f:
FOOTER = f.read()
def render(data,db_object):
if data == False:
return redirect("https://" + main_domain + '/claim?domain=' + request.host.split('.')[0])
elif data == "":
return redirect("https://" + main_domain + '/empty_site?nodata')
# Render as HTML
html = ""
ssl = ""
if ("localhost" in request.host or "127.0.0.1" in request.host):
ssl = ""
try:
soup = BeautifulSoup(data, 'html.parser')
# Inject SSL
soup.append(BeautifulSoup(ssl, 'html.parser'))
html = str(soup)
except Exception as e:
return redirect("https://" + main_domain + '/empty_site?error='+str(e))
try:
avatar = db_object['avatar']
hnschat = db_object['hnschat']
location = db_object['location']
email = db_object['email']
hns = db_object['HNS']
if 'hip2_display' in db_object:
if db_object['hip2_display'] == True:
hns = "@"+request.host
btc = db_object['BTC']
eth = db_object['ETH']
bg_colour = db_object['bg_colour']
fg_colour = db_object['fg_colour']
text_colour = db_object['text_colour']
if (rgb_to_hex(generate_foreground_color(bg_colour)) == "#000000"):
hns_icon = "assets/img/HNSW.png"
btc_icon = "assets/img/BTCW.png"
eth_icon = "assets/img/ETHW.png"
hns_icon_invert = "assets/img/HNS.png"
btc_icon_invert = "assets/img/BTC.png"
eth_icon_invert = "assets/img/ETH.png"
else:
hns_icon = "assets/img/HNS.png"
btc_icon = "assets/img/BTC.png"
eth_icon = "assets/img/ETH.png"
hns_icon_invert = "assets/img/HNSW.png"
btc_icon_invert = "assets/img/BTCW.png"
eth_icon_invert = "assets/img/ETHW.png"
if (rgb_to_hex(generate_foreground_color(fg_colour)) == "#000000"):
hns_chat_icon = "assets/img/HNS.png"
location_icon = "assets/img/map.png"
email_icon = "assets/img/email.png"
else:
hns_chat_icon = "assets/img/HNSW.png"
location_icon = "assets/img/mapw.png"
email_icon = "assets/img/emailw.png"
hns_address = hns
btc_address = btc
eth_address = eth
hns_invert = hns_address
btc_invert = btc_address
eth_invert = eth_address
if hns != "":
hns = "" + hns
hns_invert = "
" + hns_address
if btc != "":
btc = "
" + btc
btc_invert = "
" + btc_address
if eth != "":
eth = "
" + eth
eth_invert = "
" + eth_address
hide_addresses = False
if hns == "" and btc == "" and eth == "":
hide_addresses = True
if hnschat != "":
hnschat = "
" + hnschat + "/"
if location != "":
location = "
" + location
if email != "":
email = "
" + email + ""
if avatar != "":
avatar = "
"
else:
avatar = "