feat: Add HIP02 addresses
This commit is contained in:
22
sites/db.py
22
sites/db.py
@@ -32,4 +32,24 @@ def get_website_data(domain):
|
||||
# Decoding
|
||||
parsed = parsed.encode('utf-8').decode('unicode-escape')
|
||||
|
||||
return parsed
|
||||
return parsed
|
||||
|
||||
def get_website_wallet(domain,token):
|
||||
connection = mysql.connector.connect(**dbargs)
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("""
|
||||
SELECT * FROM site WHERE domain = %s
|
||||
""", (domain,))
|
||||
data = cursor.fetchall()
|
||||
cursor.close()
|
||||
connection.close()
|
||||
|
||||
if data == []:
|
||||
return ""
|
||||
|
||||
parsed = data[0][2]
|
||||
parsed = json.loads(parsed)
|
||||
if token in parsed:
|
||||
parsed = parsed[token]
|
||||
|
||||
return ""
|
||||
@@ -35,6 +35,16 @@ def index():
|
||||
return website.render(data)
|
||||
|
||||
|
||||
@app.route('/.well-known/wallets/<token>')
|
||||
def wallet(token):
|
||||
address = db.get_website_wallet(request.host.split('.')[0],token)
|
||||
if address == "":
|
||||
return redirect('/')
|
||||
# Plain text
|
||||
response = make_response(address)
|
||||
response.mimetype = "text/plain"
|
||||
return response
|
||||
|
||||
@app.route('/<path:path>')
|
||||
def catch_all(path):
|
||||
return redirect('/') # 404 catch all
|
||||
|
||||
Reference in New Issue
Block a user