mirror of
https://github.com/Py-KMS-Organization/py-kms.git
synced 2025-05-09 14:21:56 -04:00
Added sub-page for license information
This commit is contained in:
parent
03c3e1c116
commit
28e07ac7e1
6 changed files with 168 additions and 135 deletions
|
@ -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
|
||||
)
|
||||
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()
|
||||
)
|
|
@ -1 +0,0 @@
|
|||
../../LICENSE
|
35
py-kms/templates/base.html
Normal file
35
py-kms/templates/base.html
Normal file
|
@ -0,0 +1,35 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>py-kms {% block title %}{% endblock %}</title>
|
||||
<style>
|
||||
#content {
|
||||
margin: 1em;
|
||||
overflow-x: auto;
|
||||
}
|
||||
{% block style %}{% endblock %}
|
||||
</style>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename= 'css/bulma.min.css') }}">
|
||||
</head>
|
||||
<body>
|
||||
<div id="content">
|
||||
{% block content %}{% endblock %}
|
||||
</div>
|
||||
|
||||
<footer class="footer">
|
||||
<div class="content has-text-centered">
|
||||
<p>
|
||||
<strong>py-kms</strong> is online since <span class="convert_timestamp">{{ start_time }}</span>.
|
||||
This instance was accessed {{ get_serve_count() }} times. View this softwares license <a href="/license">here</a>.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script>
|
||||
for(let element of document.getElementsByClassName('convert_timestamp')) {
|
||||
element.innerText = new Date(element.innerText).toLocaleString();
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
101
py-kms/templates/clients.html
Normal file
101
py-kms/templates/clients.html
Normal file
|
@ -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 %}
|
||||
<article class="message is-danger">
|
||||
<div class="message-header">
|
||||
Whoops! Something went wrong...
|
||||
</div>
|
||||
<div class="message-body">
|
||||
{{ error }}
|
||||
</div>
|
||||
</article>
|
||||
{% else %}
|
||||
{% if clients %}
|
||||
<nav class="level">
|
||||
<div class="level-item has-text-centered">
|
||||
<div>
|
||||
<p class="heading">Clients</p>
|
||||
<p class="title">{{ count_clients }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="level-item has-text-centered">
|
||||
<div>
|
||||
<p class="heading">Windows</p>
|
||||
<p class="title">{{ count_clients_windows }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="level-item has-text-centered">
|
||||
<div>
|
||||
<p class="heading">Office</p>
|
||||
<p class="title">{{ count_clients_office }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<hr>
|
||||
|
||||
<table class="table is-striped is-hoverable is-fullwidth">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Client ID</th>
|
||||
<th>Machine Name</th>
|
||||
<th>Application ID</th>
|
||||
<th><abbr title="Stock Keeping Unit">SKU</abbr> ID</th>
|
||||
<th>License Status</th>
|
||||
<th>Last Seen</th>
|
||||
<th>KMS <abbr title="Enhanced Privacy ID">EPID</abbr></th>
|
||||
<th>Seen Count</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for client in clients %}
|
||||
<tr>
|
||||
<th><pre class="clientMachineId">{{ client.clientMachineId }}</pre></th>
|
||||
<td class="machineName">
|
||||
{% if client.machineName | length > 16 %}
|
||||
<abbr title="{{ client.machineName }}">{{ client.machineName | truncate(16, True, '...') }}</abbr>
|
||||
{% else %}
|
||||
{{ client.machineName }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ client.applicationId }}</td>
|
||||
<td>{{ client.skuId }}</td>
|
||||
<td>{{ client.licenseStatus }}</td>
|
||||
<td class="convert_timestamp">{{ client.lastRequestTime }}</td>
|
||||
<td>
|
||||
{% if client.kmsEpid | length > 16 %}
|
||||
<abbr title="{{ client.kmsEpid }}">{{ client.kmsEpid | truncate(16, True, '...') }}</abbr>
|
||||
{% else %}
|
||||
{{ client.kmsEpid }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ client.requestCount }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<article class="message is-warning">
|
||||
<div class="message-header">
|
||||
<p>Whoops?</p>
|
||||
</div>
|
||||
<div class="message-body">
|
||||
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.
|
||||
</div>
|
||||
</article>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
|
@ -1,125 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>py-kms web ui</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename= 'css/bulma.min.css') }}">
|
||||
<style>
|
||||
#content {
|
||||
margin: 1em;
|
||||
overflow-x: auto;
|
||||
}
|
||||
pre.clientMachineId {
|
||||
overflow-x: auto;
|
||||
padding: 0.5em;
|
||||
}
|
||||
th {
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="content">
|
||||
{% if error %}
|
||||
<article class="message is-danger">
|
||||
<div class="message-header">
|
||||
Whoops! Something went wrong...
|
||||
</div>
|
||||
<div class="message-body">
|
||||
{{ error }}
|
||||
</div>
|
||||
</article>
|
||||
{% else %}
|
||||
{% if clients %}
|
||||
<nav class="level">
|
||||
<div class="level-item has-text-centered">
|
||||
<div>
|
||||
<p class="heading">Clients</p>
|
||||
<p class="title">{{ count_clients }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="level-item has-text-centered">
|
||||
<div>
|
||||
<p class="heading">Windows</p>
|
||||
<p class="title">{{ count_clients_windows }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="level-item has-text-centered">
|
||||
<div>
|
||||
<p class="heading">Office</p>
|
||||
<p class="title">{{ count_clients_office }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<hr>
|
||||
|
||||
<table class="table is-striped is-hoverable is-fullwidth">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Client ID</th>
|
||||
<th>Machine Name</th>
|
||||
<th>Application ID</th>
|
||||
<th><abbr title="Stock Keeping Unit">SKU</abbr> ID</th>
|
||||
<th>License Status</th>
|
||||
<th>Last Seen</th>
|
||||
<th>KMS <abbr title="Enhanced Privacy ID">EPID</abbr></th>
|
||||
<th>Seen Count</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for client in clients %}
|
||||
<tr>
|
||||
<th><pre class="clientMachineId">{{ client.clientMachineId }}</pre></th>
|
||||
<td class="machineName">
|
||||
{% if client.machineName | length > 16 %}
|
||||
<abbr title="{{ client.machineName }}">{{ client.machineName | truncate(16, True, '...') }}</abbr>
|
||||
{% else %}
|
||||
{{ client.machineName }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ client.applicationId }}</td>
|
||||
<td>{{ client.skuId }}</td>
|
||||
<td>{{ client.licenseStatus }}</td>
|
||||
<td class="convert_timestamp">{{ client.lastRequestTime }}</td>
|
||||
<td>
|
||||
{% if client.kmsEpid | length > 16 %}
|
||||
<abbr title="{{ client.kmsEpid }}">{{ client.kmsEpid | truncate(16, True, '...') }}</abbr>
|
||||
{% else %}
|
||||
{{ client.kmsEpid }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ client.requestCount }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<article class="message is-warning">
|
||||
<div class="message-header">
|
||||
<p>Whoops?</p>
|
||||
</div>
|
||||
<div class="message-body">
|
||||
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.
|
||||
</div>
|
||||
</article>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<footer class="footer">
|
||||
<div class="content has-text-centered">
|
||||
<p>
|
||||
<strong>py-kms</strong> is online since <span class="convert_timestamp">{{ start_time }}</span>.
|
||||
This page was rendered {{ serve_count }} times. View this softwares license <a href="{{ url_for('static', filename= 'LICENSE') }}">here</a>.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script>
|
||||
for(let element of document.getElementsByClassName('convert_timestamp')) {
|
||||
element.innerText = new Date(element.innerText).toLocaleString();
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
11
py-kms/templates/license.html
Normal file
11
py-kms/templates/license.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% block title %}license{% endblock %}
|
||||
|
||||
{% block style %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<pre>{{ license }}</pre>
|
||||
{% endblock %}
|
Loading…
Add table
Add a link
Reference in a new issue