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

20
main.go
View file

@ -45,9 +45,27 @@ var (
mystromRequestsCounterVec *prometheus.CounterVec mystromRequestsCounterVec *prometheus.CounterVec
) )
var landingPage = []byte(`<html> 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> <body>
<h1>myStrom Exporter</h1> <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> <p><a href='` + *metricsPath + `'>Metrics</a></p>
</body> </body>
</html>`) </html>`)