Implement license validation endpoint and update templates; add test script

This commit is contained in:
Maximilian G.
2026-03-22 14:49:38 +00:00
committed by GitHub
parent 5e0c77b147
commit 91feb7d010
6 changed files with 20 additions and 14 deletions
+2 -1
View File
@@ -1,3 +1,4 @@
.venv
__pycache__
build
build
main.dist
+11 -7
View File
@@ -1,9 +1,7 @@
from pathlib import Path
import sys
from flask import Flask, render_template
from flask import Flask, render_template, request, jsonify
import verify
import requests
import json
def _resolve_template_dir() -> Path:
candidates = [
@@ -38,9 +36,9 @@ def _read_app_version() -> str:
APP_VERSION = _read_app_version()
@app.route("/_validate__information", methods=['POST'])
def default():
data = requests.get_json()
@app.route("/validate__information", methods=['POST'])
def validate__information():
data = request.get_json(silent=True)
if not data:
return jsonify({"error": "No JSON data provided"}), 400
license_key = data.get("license")
@@ -48,7 +46,13 @@ def default():
if not license_key or not hwid_uuid:
return jsonify({"error": "Missing 'license' or 'hwid' in JSON data"}), 400
if verify.check(license_key, hwid_uuid):
return 200
return jsonify({"status": "ok"}), 200
else:
return jsonify({"status": "invalid"}), 402
@app.route("/")
def default():
return render_template("main.html")
def main():
+1 -3
View File
@@ -1,4 +1,2 @@
<a>This is a Test If this works it would be great!</a>
<p>Version: {{ version }}</p>
<p>UUID: {{ uuid }}</p>
<p>License Key: {{ license }}</p>
<p>Version: {{ version }}</p>
+1 -1
View File
@@ -2,7 +2,7 @@ import json
import os
import secrets
LICENSES_FILE = os.path.abspath(os.path.join(os.path.dirname(__file__), "licenses.json"))
LICENSES_FILE = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "licenses.json"))
def load_file() -> dict:
+2 -2
View File
@@ -31,7 +31,7 @@
},
{
"user_id": "0007",
"license_key": "OW-vmNd7P_Xyije4Nv7fcytwkawcUOUDrbWR3YFYYlU",
"hwid_uuid": ""
"license_key": "TEST-KEY-123",
"hwid_uuid": "HWID-ABC-999"
}
]
Executable
+3
View File
@@ -0,0 +1,3 @@
curl -i -X POST "http://127.0.0.1:5000/validate__information" \
-H "Content-Type: application/json" \
-d '{"license":"npEDI1JVhyisQ2dg-fWTTAn5H1hg3eS80Zc-4IptWIU=","hwid":""}'