I'm trying to do a simple thing. I have a website and I want people to be able to send some feedback and warn me, for that i have a "Notify Owner" button which displays a form and on Submit should execute a python script that send myself an email with the information they filled.
This is my form code (index.html - Created on the client side)
<script>
async function notifyOwner() {
await fetch("api/notify", { method: "post" }).catch(console.log);
}
</script>
<div class="form-popup" id="myForm">
<form class="form-container" name="form-owner">
<h1>Notify Owner</h1>
<label><b>Name</b></label>
<input id="name" style="width:90%" type="text" placeholder="Enter your name$
<label><b>Message</b></label>
<input id="context" style="width:90%" type="text" placeholder="Enter Reason$
<button type="submit" class="btn" onclick="notifyOwner()">Submit</button>
<button type="button" class="btn cancel" onclick="closeForm()">Close</butto$
</form>
</div>
This is my server side handling
app.post("/api/notify", async (req, res) => {
try{
var subject = "teste";
var body = "ok";
child_process.execSync('python3 sendEmail.py ' + subject + " " + body);
}catch(error){
console.error(error);
}
});
what should I do to replace the var subject with the value from id="name" and replace the var body with the value from id="context"?