Compare commits
No commits in common. "master" and "main" have entirely different histories.
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 9f619f0651d557117425bfa8482947698bd40485
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
FROM python:3.9
|
|
||||||
WORKDIR /app
|
|
||||||
COPY . .
|
|
||||||
RUN pip install fastapi uvicorn
|
|
||||||
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "6661"]
|
|
||||||
|
|
@ -1,73 +0,0 @@
|
||||||
from fastapi import FastAPI, HTTPException
|
|
||||||
from pydantic import BaseModel
|
|
||||||
import sqlite3
|
|
||||||
import datetime
|
|
||||||
|
|
||||||
app = FastAPI()
|
|
||||||
|
|
||||||
# Создаем соединение с базой данных
|
|
||||||
conn = sqlite3.connect("/db/rustdesk.db", check_same_thread=False)
|
|
||||||
cursor = conn.cursor()
|
|
||||||
|
|
||||||
# Создаем таблицу, если её нет
|
|
||||||
cursor.execute("""
|
|
||||||
CREATE TABLE IF NOT EXISTS installs (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
rust_id TEXT,
|
|
||||||
computer_name TEXT,
|
|
||||||
install_time TEXT
|
|
||||||
)
|
|
||||||
""")
|
|
||||||
conn.commit()
|
|
||||||
|
|
||||||
# Модель данных
|
|
||||||
class InstallData(BaseModel):
|
|
||||||
rust_id: str
|
|
||||||
computer_name: str
|
|
||||||
install_time: str
|
|
||||||
|
|
||||||
# Маршрут для получения всех записей
|
|
||||||
@app.get("/api/installs")
|
|
||||||
def get_installs():
|
|
||||||
cursor.execute("SELECT * FROM installs")
|
|
||||||
rows = cursor.fetchall()
|
|
||||||
# Преобразуем результаты в список словарей
|
|
||||||
result = []
|
|
||||||
for row in rows:
|
|
||||||
result.append({
|
|
||||||
"id": row[0],
|
|
||||||
"rust_id": row[1],
|
|
||||||
"computer_name": row[2],
|
|
||||||
"install_time": row[3]
|
|
||||||
})
|
|
||||||
return result
|
|
||||||
|
|
||||||
# Маршрут для добавления новой записи
|
|
||||||
@app.post("/api/install")
|
|
||||||
def add_install(data: InstallData):
|
|
||||||
cursor.execute("INSERT INTO installs (rust_id, computer_name, install_time) VALUES (?, ?, ?)",
|
|
||||||
(data.rust_id, data.computer_name, data.install_time))
|
|
||||||
conn.commit()
|
|
||||||
return {"status": "success"}
|
|
||||||
|
|
||||||
# Добавляем маршрут для удаления записи
|
|
||||||
@app.delete("/api/delete/{install_id}")
|
|
||||||
async def delete_install(install_id: int):
|
|
||||||
try:
|
|
||||||
cursor.execute("DELETE FROM installs WHERE id = ?", (install_id,))
|
|
||||||
conn.commit()
|
|
||||||
if cursor.rowcount == 0:
|
|
||||||
raise HTTPException(status_code=404, detail="Запись не найдена")
|
|
||||||
return {"status": "success"}
|
|
||||||
except Exception as e:
|
|
||||||
raise HTTPException(status_code=500, detail=str(e))
|
|
||||||
|
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
|
||||||
|
|
||||||
app.add_middleware(
|
|
||||||
CORSMiddleware,
|
|
||||||
allow_origins=["http://10.0.0.10:8080", "http://localhost:8080"], # Добавляем localhost
|
|
||||||
allow_credentials=True,
|
|
||||||
allow_methods=["*"],
|
|
||||||
allow_headers=["*"],
|
|
||||||
)
|
|
||||||
BIN
db/rustdesk.db
BIN
db/rustdesk.db
Binary file not shown.
BIN
db_v2.sqlite3
BIN
db_v2.sqlite3
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,16 +0,0 @@
|
||||||
version: '3.8'
|
|
||||||
|
|
||||||
services:
|
|
||||||
backend:
|
|
||||||
build: ./backend
|
|
||||||
ports:
|
|
||||||
- "6661:6661"
|
|
||||||
volumes:
|
|
||||||
- ./db:/db
|
|
||||||
|
|
||||||
frontend:
|
|
||||||
build: ./frontend
|
|
||||||
ports:
|
|
||||||
- "8080:8080"
|
|
||||||
volumes:
|
|
||||||
- ./db:/db
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
FROM python:3.9
|
|
||||||
WORKDIR /app
|
|
||||||
COPY . .
|
|
||||||
RUN pip install flask
|
|
||||||
CMD ["python", "app.py"]
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
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)
|
|
||||||
|
|
@ -1,69 +0,0 @@
|
||||||
<!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>
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
mTw9iat3pA3TccDTjkWWnxaD+bYS9CCelt/DLdBB0wgVLAAM2LqeF0OOgARmU+LVmiKGQ3c53XbsyPJw4O8gvw==
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
FSwADNi6nhdDjoAEZlPi1ZoihkN3Od127MjycODvIL8=
|
|
||||||
Loading…
Reference in New Issue