first commit

This commit is contained in:
hendrik 2024-05-25 03:13:52 +02:00
commit d73d983d0f
6 changed files with 140 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.*.sw*

35
css/style.css Normal file
View File

@ -0,0 +1,35 @@
#hierarchy
{
font-family: FontAwesome;
width: 300px;
}
.foldercontainer, .file, .noitems
{
display: block;
padding: 5px 5px 5px 50px;
}
.folder
{
color: red;
}
.file
{
color: green;
}
.folder, .file
{
cursor: pointer;
}
.noitems
{
display: none;
pointer-events: none;
}
.folder:hover,.file:hover
{
background: yellow;
}
.folder:before, .file:before
{
padding-right: 10px;
}

40
index.html Normal file
View File

@ -0,0 +1,40 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap demo</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="container mt-5">
<h1>Hello, world!</h1>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
<form action="/test.py" method="get">
<label for="path">Path</label></br>
<input type="text" id="path" name="path">
<input type="submit" value="Submit" class="btn btn-primary">
</form>
<!--button type="button" class="btn btn-primary" onclick="runpy()"> >Primary</button>
<button type="button" class="btn btn-secondary">Secondary</button>
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-danger">Danger</button>
<button type="button" class="btn btn-warning">Warning</button>
<button type="button" class="btn btn-info">Info</button>
<button type="button" class="btn btn-light">Light</button>
<button type="button" class="btn btn-dark">Dark</button>
<button type="button" class="btn btn-link">Link</button-->
<h2> file structure </h2>
<div id="hierarchy"></div>
<h2> Some table </h2>
<div id="table-container">
</div>
</div>
<script src="table_builder.js" defer></script>
</body>
</html>

15
script/test.py Executable file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env python3
import os
import json
dir="/data/media/tmp/The.IT.Crowd.S01/input"
data = [ { "name" : l} for l in os.listdir(dir)]
print("Content-Type: application/json\n")
print(json.dumps(data));

41
table_builder.js Normal file
View File

@ -0,0 +1,41 @@
function fetchTable(fetcher,table_container , param) {
let url = '/script/' + fetcher + '?param=' + encodeURIComponent(param);
fetch(url)
.then(response => response.json())
.then(data => {
let table = document.createElement('table');
table.border = '1';
let header = table.createTHead();
let headerRow = header.insertRow(0);
let i=0;
let keys = [];
for (key in data[0]) {
let new_cell = headerRow.insertCell(i);
new_cell.innerHTML = "<b>" + key + "</b>";
keys.push(key);
i = i+1;
}
let tbody = table.createTBody();
data.forEach(el => {
let row = tbody.insertRow();
keys.forEach((k,i) => {
let cell1 = row.insertCell(0);
cell1.innerHTML = el[k];
});
});
document.getElementById(table_container).appendChild(table);
})
.catch(error => console.error('Error fetching table data:', error));
}
window.onload = function() {
let foo = "Bar";
fetchTable('test.py', 'table-container', foo);
}

8
test.py Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env python3
dir="/data/media/tmp/The.IT.Crowd.S01/input"
print("Content-Type: text/html\n")
print("<html><body>")
print("<h1>Hello from Python script!</h1>")
print("</body></html>")