Add initial project structure with main application logic, templates, and license management
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user