feat: Add wallet addresses
All checks were successful
Build Docker / Build Image (push) Successful in 37s

This commit is contained in:
Nathan Woodburn 2023-11-02 21:51:49 +11:00
parent f001691283
commit 66acd69bec
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
2 changed files with 25 additions and 1 deletions

View File

@ -1,3 +1,4 @@
flask flask
python-dotenv python-dotenv
gunicorn gunicorn
requests

View File

@ -1,6 +1,7 @@
from flask import Flask, make_response, redirect, request, jsonify, render_template, send_from_directory from flask import Flask, make_response, redirect, request, jsonify, render_template, send_from_directory
import os import os
import dotenv import dotenv
import requests
app = Flask(__name__) app = Flask(__name__)
dotenv.load_dotenv() dotenv.load_dotenv()
@ -56,6 +57,28 @@ def handshake():
def removeTrailingSlash(): def removeTrailingSlash():
return render_template(request.path.split('/')[-2] + '.html') return render_template(request.path.split('/')[-2] + '.html')
@app.route('/.well-known/wallets/<path:path>')
def wallet(path):
# If HNS, redirect to HNS wallet
if path == "HNS":
# Get from 100.66.107.77:8080 then return result
# Check for cookie
if request.cookies.get('HNS'):
print(request.cookies.get('HNS'))
return make_response(request.cookies.get('HNS'), 200, {'Content-Type': 'text/plain'})
address = requests.get('http://100.66.107.77:8080')
# Set cookie
resp = make_response(address.text, 200, {'Content-Type': 'text/plain'})
resp.set_cookie('HNS', address.text)
return resp
return send_from_directory('.well-known/wallets', path, mimetype='text/plain')
# Main routes # Main routes
@app.route('/') @app.route('/')
def index(): def index():