Add initial project structure with main application logic, templates, and license management
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
.venv
|
||||
__pycache__
|
||||
build
|
||||
@@ -0,0 +1,54 @@
|
||||
from pathlib import Path
|
||||
import sys
|
||||
from flask import Flask, render_template
|
||||
import verify
|
||||
import requests
|
||||
import json
|
||||
|
||||
def _resolve_template_dir() -> Path:
|
||||
candidates = [
|
||||
Path(__file__).resolve().parent / "templates",
|
||||
Path(sys.argv[0]).resolve().parent / "templates",
|
||||
Path.cwd() / "templates",
|
||||
]
|
||||
|
||||
for path in candidates:
|
||||
if path.is_dir():
|
||||
return path
|
||||
|
||||
return candidates[0]
|
||||
|
||||
|
||||
app = Flask(__name__, template_folder=str(_resolve_template_dir()))
|
||||
|
||||
|
||||
def _read_app_version() -> str:
|
||||
candidates = [
|
||||
Path(__file__).resolve().parent / "version.txt",
|
||||
Path(sys.argv[0]).resolve().parent / "version.txt",
|
||||
Path.cwd() / "version.txt",
|
||||
]
|
||||
|
||||
for path in candidates:
|
||||
if path.is_file():
|
||||
return path.read_text(encoding="utf-8").strip() or "unknown"
|
||||
|
||||
return "unknown"
|
||||
|
||||
|
||||
APP_VERSION = _read_app_version()
|
||||
|
||||
@app.route("/_validate__information", methods=['POST'])
|
||||
def default():
|
||||
data = requests.get_json()
|
||||
if not data:
|
||||
return jsonify({"error": "No JSON data provided"}), 400
|
||||
license_key = data.get("license")
|
||||
hwid_uuid = data.get("hwid")
|
||||
|
||||
|
||||
def main():
|
||||
app.run(host="0.0.0.0", port=5000, debug=False)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,4 @@
|
||||
<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>
|
||||
@@ -0,0 +1,50 @@
|
||||
import json
|
||||
import os
|
||||
import secrets
|
||||
|
||||
LICENSES_FILE = os.path.abspath(os.path.join(os.path.dirname(__file__), "licenses.json"))
|
||||
|
||||
|
||||
def load_file() -> dict:
|
||||
with open(LICENSES_FILE, "r") as f:
|
||||
data = json.load(f)
|
||||
return data
|
||||
|
||||
def check(license_key, hwid_uuid) -> bool:
|
||||
data = load_file()
|
||||
for i in data:
|
||||
if str(i["license_key"]) == str(license_key):
|
||||
if str(i["hwid_uuid"]) == str(hwid_uuid):
|
||||
return True
|
||||
elif str(i["hwid_uuid"]) == "":
|
||||
i["hwid_uuid"] = str(hwid_uuid)
|
||||
register_new_Key(data)
|
||||
return True
|
||||
return False
|
||||
|
||||
def register_new_Key(data_stream):
|
||||
with open(LICENSES_FILE, "w") as f:
|
||||
json.dump(data_stream, f, indent=2)
|
||||
|
||||
def new_key() -> str:
|
||||
data = load_file()
|
||||
existing_ids = []
|
||||
for item in data:
|
||||
user_id = str(item.get("user_id", "")).strip()
|
||||
if user_id.isdigit():
|
||||
existing_ids.append(int(user_id))
|
||||
|
||||
next_id = (max(existing_ids) + 1) if existing_ids else 1
|
||||
generated_key = key_generator()
|
||||
data.append(
|
||||
{
|
||||
"user_id": f"{next_id:04d}",
|
||||
"license_key": generated_key,
|
||||
"hwid_uuid": "",
|
||||
}
|
||||
)
|
||||
register_new_Key(data)
|
||||
return generated_key
|
||||
|
||||
def key_generator():
|
||||
return secrets.token_urlsafe(32)
|
||||
@@ -0,0 +1 @@
|
||||
0.1.0
|
||||
@@ -0,0 +1,37 @@
|
||||
[
|
||||
{
|
||||
"user_id": "0001",
|
||||
"license_key": "npEDI1JVhyisQ2dg-fWTTAn5H1hg3eS80Zc-4IptWIU=",
|
||||
"hwid_uuid": "0c27aefd7107396933c7363efa38fb6c297aa3db119c1597952c05d947f4f27c"
|
||||
},
|
||||
{
|
||||
"user_id": "0002",
|
||||
"license_key": "qclcig8LitaXJGC4zqcZ3xFULlUinzGAOBYB07YGrTA=",
|
||||
"hwid_uuid": "0c27aefd7107396933c7363efa38fb6c297aa3db119c1597952c05d947f4f37c"
|
||||
},
|
||||
{
|
||||
"user_id": "0003",
|
||||
"license_key": "1ylfo4_4KygPSnyM7jU4xYCK2Qr_d7N0xTULruy3j9w",
|
||||
"hwid_uuid": "0c27aefd7107396933c7363efa38fb6c297aa3db119c1597952c05d947f4f47c"
|
||||
},
|
||||
{
|
||||
"user_id": "0004",
|
||||
"license_key": "vEJP5i4FTnVGZq2vLz24-jecgMW5ZmHYawyTXKna9yA",
|
||||
"hwid_uuid": ""
|
||||
},
|
||||
{
|
||||
"user_id": "0005",
|
||||
"license_key": "AtEdMFq1v86DHTE-W5fDav7KFu-BpFeQUFP6IQPOfUc",
|
||||
"hwid_uuid": ""
|
||||
},
|
||||
{
|
||||
"user_id": "0006",
|
||||
"license_key": "dmPn1wDgVcv_5rowayGjABQel2TQov2IdtIuteLzRM8",
|
||||
"hwid_uuid": ""
|
||||
},
|
||||
{
|
||||
"user_id": "0007",
|
||||
"license_key": "OW-vmNd7P_Xyije4Nv7fcytwkawcUOUDrbWR3YFYYlU",
|
||||
"hwid_uuid": ""
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if [[ -n "${CONDA_DEFAULT_ENV:-}" ]] && command -v conda >/dev/null 2>&1; then
|
||||
conda deactivate || true
|
||||
fi
|
||||
|
||||
source .venv/bin/activate
|
||||
|
||||
# Do not run apt here because third-party repos in dev containers can fail.
|
||||
# We only check and provide the install hint if patchelf is missing.
|
||||
if ! command -v patchelf >/dev/null 2>&1; then
|
||||
echo "Error: patchelf is required for Nuitka standalone builds on Linux."
|
||||
echo "Install with: sudo apt update && sudo apt install -y patchelf"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pip install -U nuitka ordered-set zstandard flask cryptography
|
||||
python - <<'PY'
|
||||
from pathlib import Path
|
||||
import json
|
||||
|
||||
root = Path.cwd()
|
||||
settings_path = root / "settings.json"
|
||||
version_file = root / "Code" / "version.txt"
|
||||
|
||||
version = "0.1.0"
|
||||
if settings_path.is_file():
|
||||
raw = settings_path.read_text(encoding="utf-8").strip()
|
||||
if raw:
|
||||
data = json.loads(raw)
|
||||
if isinstance(data, dict):
|
||||
version = str(data.get("version", version)).strip() or version
|
||||
elif isinstance(data, list):
|
||||
for item in data:
|
||||
if isinstance(item, dict) and "version" in item:
|
||||
version = str(item.get("version", version)).strip() or version
|
||||
break
|
||||
|
||||
version_file.write_text(f"{version}\n", encoding="utf-8")
|
||||
print(f"Prepared {version_file} with version: {version}")
|
||||
PY
|
||||
python -m nuitka --standalone --follow-imports --include-data-dir=Code/templates=templates --include-data-file=licenses.json=licenses.json --assume-yes-for-downloads --output-dir=build --remove-output Code/main.py
|
||||
if [[ -x "./build/main.dist/main.bin" ]]; then
|
||||
./build/main.dist/main.bin
|
||||
else
|
||||
echo "Build step finished but executable not found at ./build/main.dist/main.bin"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user