Implement license validation endpoint and update templates; add test script
This commit is contained in:
+2
-1
@@ -1,3 +1,4 @@
|
||||
.venv
|
||||
__pycache__
|
||||
build
|
||||
build
|
||||
main.dist
|
||||
+11
-7
@@ -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,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
@@ -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
@@ -31,7 +31,7 @@
|
||||
},
|
||||
{
|
||||
"user_id": "0007",
|
||||
"license_key": "OW-vmNd7P_Xyije4Nv7fcytwkawcUOUDrbWR3YFYYlU",
|
||||
"hwid_uuid": ""
|
||||
"license_key": "TEST-KEY-123",
|
||||
"hwid_uuid": "HWID-ABC-999"
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user