diff --git a/py-kms/pykms_WebUI.py b/py-kms/pykms_WebUI.py index 7f8b576..1030b67 100644 --- a/py-kms/pykms_WebUI.py +++ b/py-kms/pykms_WebUI.py @@ -2,14 +2,19 @@ import os, uuid, datetime from flask import Flask, render_template from pykms_Sql import sql_get_all -app = Flask('pykms_webui') - -start_time = datetime.datetime.now() serve_count = 0 def _random_uuid(): return str(uuid.uuid4()).replace('-', '_') +def _get_serve_count(): + return serve_count + +app = Flask('pykms_webui') +app.jinja_env.globals['start_time'] = datetime.datetime.now() +app.jinja_env.globals['get_serve_count'] = _get_serve_count +app.jinja_env.globals['random_uuid'] = _random_uuid + @app.route('/') def root(): global serve_count @@ -33,13 +38,20 @@ def root(): countClientsWindows = len([c for c in clients if c['applicationId'] == 'Windows']) if clients else 0 countClientsOffice = countClients - countClientsWindows return render_template( - 'index.html', - start_time=start_time.isoformat(), + 'clients.html', error=error, clients=clients, count_clients=countClients, count_clients_windows=countClientsWindows, - count_clients_office=countClientsOffice, - serve_count=serve_count, - random_uuid=_random_uuid - ) \ No newline at end of file + count_clients_office=countClientsOffice + ) + +@app.route('/license') +def license(): + global serve_count + serve_count += 1 + with open('../LICENSE', 'r') as f: + return render_template( + 'license.html', + license=f.read() + ) \ No newline at end of file diff --git a/py-kms/static/LICENSE b/py-kms/static/LICENSE deleted file mode 120000 index 30cff74..0000000 --- a/py-kms/static/LICENSE +++ /dev/null @@ -1 +0,0 @@ -../../LICENSE \ No newline at end of file diff --git a/py-kms/templates/base.html b/py-kms/templates/base.html new file mode 100644 index 0000000..28c22ce --- /dev/null +++ b/py-kms/templates/base.html @@ -0,0 +1,35 @@ + + + + + py-kms {% block title %}{% endblock %} + + + + +
+ {% block content %}{% endblock %} +
+ + + + + + \ No newline at end of file diff --git a/py-kms/templates/clients.html b/py-kms/templates/clients.html new file mode 100644 index 0000000..d1e6e29 --- /dev/null +++ b/py-kms/templates/clients.html @@ -0,0 +1,101 @@ +{% extends 'base.html' %} + +{% block title %}clients{% endblock %} + +{% block style %} + pre.clientMachineId { + overflow-x: auto; + padding: 0.5em; + } + th { + white-space: nowrap; + } +{% endblock %} + +{% block content %} +{% if error %} +
+
+ Whoops! Something went wrong... +
+
+ {{ error }} +
+
+{% else %} +{% if clients %} + + +
+ + + + + + + + + + + + + + + + {% for client in clients %} + + + + + + + + + + + {% endfor %} + +
Client IDMachine NameApplication IDSKU IDLicense StatusLast SeenKMS EPIDSeen Count
{{ client.clientMachineId }}
+ {% if client.machineName | length > 16 %} + {{ client.machineName | truncate(16, True, '...') }} + {% else %} + {{ client.machineName }} + {% endif %} + {{ client.applicationId }}{{ client.skuId }}{{ client.licenseStatus }}{{ client.lastRequestTime }} + {% if client.kmsEpid | length > 16 %} + {{ client.kmsEpid | truncate(16, True, '...') }} + {% else %} + {{ client.kmsEpid }} + {% endif %} + {{ client.requestCount }}
+{% else %} +
+
+

Whoops?

+
+
+ This page seems to be empty, because no clients are available. Try to use the server with a compartible client to add it to the database. +
+
+{% endif %} +{% endif %} +{% endblock %} \ No newline at end of file diff --git a/py-kms/templates/index.html b/py-kms/templates/index.html deleted file mode 100644 index 1db0335..0000000 --- a/py-kms/templates/index.html +++ /dev/null @@ -1,125 +0,0 @@ - - - - - py-kms web ui - - - - -
- {% if error %} -
-
- Whoops! Something went wrong... -
-
- {{ error }} -
-
- {% else %} - {% if clients %} - - -
- - - - - - - - - - - - - - - - {% for client in clients %} - - - - - - - - - - - {% endfor %} - -
Client IDMachine NameApplication IDSKU IDLicense StatusLast SeenKMS EPIDSeen Count
{{ client.clientMachineId }}
- {% if client.machineName | length > 16 %} - {{ client.machineName | truncate(16, True, '...') }} - {% else %} - {{ client.machineName }} - {% endif %} - {{ client.applicationId }}{{ client.skuId }}{{ client.licenseStatus }}{{ client.lastRequestTime }} - {% if client.kmsEpid | length > 16 %} - {{ client.kmsEpid | truncate(16, True, '...') }} - {% else %} - {{ client.kmsEpid }} - {% endif %} - {{ client.requestCount }}
- {% else %} -
-
-

Whoops?

-
-
- This page seems to be empty, because no clients are available. Try to use the server with a compartible client to add it to the database. -
-
- {% endif %} - {% endif %} -
- - - - - - \ No newline at end of file diff --git a/py-kms/templates/license.html b/py-kms/templates/license.html new file mode 100644 index 0000000..be9cca7 --- /dev/null +++ b/py-kms/templates/license.html @@ -0,0 +1,11 @@ +{% extends 'base.html' %} + +{% block title %}license{% endblock %} + +{% block style %} + +{% endblock %} + +{% block content %} +
{{ license }}
+{% endblock %} \ No newline at end of file