first commit

This commit is contained in:
Administrator 2023-10-07 13:46:29 +00:00
parent e14b1c60e6
commit f4fa3585f9
3 changed files with 53 additions and 0 deletions

26
build.py Normal file
View File

@ -0,0 +1,26 @@
import csv
import logging
def wrap_url(u):
if u.startswith("http"):
return u
return f'http://{u}'
if __name__ == '__main__':
subst = ''
with open('src/src.csv') as file:
logging.info('reading csv')
reader = csv.DictReader(file)
for row in reader:
subst += f'<tr><td>{row['service']}</td><td>'
f'<a target="_blank" href="{wrap_url(row["url"])}">{row["url"]}</a></td>'
f'<td><a target="_blank" href="{wrap_url(row["ip"])}">{row["ip"]}</a></td>'
f'<td>{row["comment"]}</td>'
logging.info('write file')
with open('template/template.html') as inf:
with open('public/index.html', 'w') as outf:
outf.write(inf.read().replace('<!--Placeholder-->',subst))
logging.info('done')

2
src/src.csv Normal file
View File

@ -0,0 +1,2 @@
service,url,ip,comment
Resilio Sync,,10.80.15.3:8080,
1 service url ip comment
2 Resilio Sync 10.80.15.3:8080

25
template/template.html Normal file
View File

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Service List</title>
</head>
<body>
<h1>Service List</h1>
<table>
<thead>
<tr>
<th>Service</th>
<th>URL</th>
<th>IP</th>
<th>Comment</th>
</tr>
</thead>
<tbody>
<!--Placeholder-->
</tbody>
</table>
</body>
</html>