Add form to index page, similar to snmp exporter

This commit is contained in:
Mathias Petermann 2022-08-29 22:00:05 +02:00
parent 896f84f57b
commit 81fcbc12d9
No known key found for this signature in database
GPG Key ID: DADC3DF6E81B66C1
1 changed files with 19 additions and 1 deletions

20
main.go
View File

@ -45,9 +45,27 @@ var (
mystromRequestsCounterVec *prometheus.CounterVec
)
var landingPage = []byte(`<html>
<head><title>myStrom switch report Exporter</title></head>
<head>
<title>myStrom switch report Exporter</title>
<style>
label{
display:inline-block;
width:75px;
}
form label {
margin: 10px;
}
form input {
margin: 10px;
}
</style>
</head>
<body>
<h1>myStrom Exporter</h1>
<form action="` + *devicePath + `">
<label>Target:</label> <input type="text" name="target" placeholder="X.X.X.X" value="1.2.3.4"><br>
<input type="submit" value="Submit">
</form>
<p><a href='` + *metricsPath + `'>Metrics</a></p>
</body>
</html>`)