feat: Create api server for hs-anyone
All checks were successful
Build Docker / BuildImage (push) Successful in 45s

This commit is contained in:
Nathan Woodburn 2024-10-03 13:50:10 +10:00
parent 613007f436
commit 1f2dbe0e99
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

View File

@ -15,6 +15,7 @@ import json
import requests
from datetime import datetime
import dotenv
import subprocess
dotenv.load_dotenv()
@ -67,6 +68,31 @@ def wellknown(path):
req.content, 200, {"Content-Type": req.headers["Content-Type"]}
)
@app.route("/renew", methods=["POST"])
def renew():
# Get post data
data = request.get_json()
if not data:
return jsonify({"error": "No data provided"}), 400
# Get the domain
domain = data.get("domain")
if not domain:
return jsonify({"error": "No domain provided"}), 400
# Get path from env
path = os.getenv("PATH")
wallet = os.getenv("WALLET")
apiKEY = os.getenv("API_KEY")
if not path:
return jsonify({"error": "No HS-ANYONE found"}), 400
# Run the renewal
output = subprocess.run(["node", path, "renew", domain, "--wallet", wallet, "--network", "main", "--broadcast", "true", "--apikey", apiKEY], capture_output=True, text=True)
return jsonify({"output": output.stdout,"error": output.stderr}), 200
# endregion