forked from mattronix/escpos-go-labels
remove crap
This commit is contained in:
parent
15177f67c9
commit
7b5c804ec8
2 changed files with 91 additions and 0 deletions
90
label.html
Normal file
90
label.html
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
<!-- FILEPATH: index.html -->
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Create DNH Label</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
background-color: #f2f2f2;
|
||||||
|
margin: 0;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
color: #333;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
form {
|
||||||
|
max-width: 400px;
|
||||||
|
margin: 0 auto;
|
||||||
|
background-color: #fff;
|
||||||
|
padding: 20px;
|
||||||
|
border-radius: 5px;
|
||||||
|
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="text"] {
|
||||||
|
width: 100%;
|
||||||
|
padding: 10px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 4px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="submit"] {
|
||||||
|
background-color: #4CAF50;
|
||||||
|
color: white;
|
||||||
|
padding: 10px 20px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 4px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="submit"]:hover {
|
||||||
|
background-color: #45a049;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Create DNH Label</h1>
|
||||||
|
<form id="labelForm" action="http://indicio.ti:8080/create_dnh_label" method="POST">
|
||||||
|
<label for="name">Name:</label>
|
||||||
|
<input type="text" id="name" name="name" required>
|
||||||
|
<br><br>
|
||||||
|
<input type="submit" value="Create Label">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
document.getElementById("labelForm").addEventListener("submit", function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
var form = event.target;
|
||||||
|
var formData = new FormData(form);
|
||||||
|
|
||||||
|
fetch(form.action, {
|
||||||
|
method: form.method,
|
||||||
|
body: formData
|
||||||
|
})
|
||||||
|
.then(function(response) {
|
||||||
|
if (response.ok) {
|
||||||
|
alert("Label created successfully!");
|
||||||
|
} else {
|
||||||
|
console.log(response);
|
||||||
|
alert("Failed to create label. Please try again.");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(function(error) {
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
1
main.go
1
main.go
|
@ -122,4 +122,5 @@ func createDnhLabelHandler(w http.ResponseWriter, r *http.Request, ep *escpos.Es
|
||||||
ep.WriteRaw([]byte{12}) // FF: in Page mode, prints all the data in the print buffer collectively and switches from Page mode to Standard mode.
|
ep.WriteRaw([]byte{12}) // FF: in Page mode, prints all the data in the print buffer collectively and switches from Page mode to Standard mode.
|
||||||
ep.Cut()
|
ep.Cut()
|
||||||
ep.End()
|
ep.End()
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
}
|
}
|
Loading…
Reference in a new issue