generated from nathanwoodburn/python-webserver-template
feat: Add api route to get domain info
All checks were successful
Build Docker / BuildImage (push) Successful in 42s
All checks were successful
Build Docker / BuildImage (push) Successful in 42s
This commit is contained in:
20
server.py
20
server.py
@@ -68,6 +68,26 @@ def wellknown(path):
|
||||
req.content, 200, {"Content-Type": req.headers["Content-Type"]}
|
||||
)
|
||||
|
||||
@app.route("/verify", methods=["GET"])
|
||||
def verify_domain():
|
||||
# Get the domain from the query string
|
||||
domain = request.args.get("domain")
|
||||
if not domain:
|
||||
return jsonify({"error": "No domain provided"}), 400
|
||||
|
||||
# Get path from env
|
||||
apiKEY = os.getenv("API_KEY")
|
||||
# Get host or use 127.0.0.1
|
||||
host = os.getenv("HSD_HOST", "127.0.0.1")
|
||||
nameInfo = requests.post(
|
||||
f"http://x:{apiKEY}@{host}:12037",
|
||||
json={
|
||||
"method": "getnameinfo",
|
||||
"params": [domain]
|
||||
}
|
||||
)
|
||||
return jsonify(nameInfo.json()), 200
|
||||
|
||||
@app.route("/renew", methods=["POST"])
|
||||
def renew():
|
||||
# Get post data
|
||||
|
||||
Reference in New Issue
Block a user