Initial commit
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
FROM python:3.9
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN pip install flask
|
||||
CMD ["python", "app.py"]
|
||||
@@ -0,0 +1,16 @@
|
||||
from flask import Flask, render_template
|
||||
import sqlite3
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route("/")
|
||||
def index():
|
||||
conn = sqlite3.connect("/db/rustdesk.db")
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("SELECT * FROM installs")
|
||||
data = cursor.fetchall()
|
||||
conn.close()
|
||||
return render_template("index.html", installs=data)
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host="0.0.0.0", port=8080, debug=True)
|
||||
@@ -0,0 +1,69 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Установки RustDesk</title>
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.min.js"></script>
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.11.5/css/jquery.dataTables.min.css">
|
||||
<script>
|
||||
const API_URL = "/api";
|
||||
|
||||
$(document).ready(function () {
|
||||
$.getJSON(`${API_URL}/installs`, function (data) {
|
||||
console.log("Полученные данные:", data);
|
||||
|
||||
let table = $('#rustdeskTable').DataTable({
|
||||
"order": [[3, "desc"]],
|
||||
"destroy": true,
|
||||
"data": data,
|
||||
"columns": [
|
||||
{ "data": "id" },
|
||||
{ "data": "rust_id" },
|
||||
{ "data": "computer_name" },
|
||||
{ "data": "install_time" },
|
||||
{
|
||||
"data": "id",
|
||||
"render": function (data) {
|
||||
return `<button onclick="deleteEntry(${data})">Удалить</button>`;
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
}).fail(function(jqXHR, textStatus, errorThrown) {
|
||||
console.error("Ошибка загрузки данных:", textStatus, errorThrown);
|
||||
});
|
||||
|
||||
window.deleteEntry = function(id) {
|
||||
if (confirm("Вы уверены, что хотите удалить запись?")) {
|
||||
$.ajax({
|
||||
url: `${API_URL}/delete/${id}`,
|
||||
type: 'DELETE',
|
||||
success: function () {
|
||||
location.reload();
|
||||
},
|
||||
error: function () {
|
||||
alert("Ошибка при удалении!");
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Установки RustDesk</h1>
|
||||
<table id="rustdeskTable" class="display">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Rust ID</th>
|
||||
<th>Имя компьютера</th>
|
||||
<th>Время установки</th>
|
||||
<th>Действие</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user