Spaces:
Sleeping
Sleeping
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Create Pole Record</title> | |
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"> | |
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> | |
</head> | |
<body> | |
<div class="container mt-5"> | |
<h2>Create Pole Record</h2> | |
<form id="createPoleForm"> | |
<div class="form-group"> | |
<label for="name">Pole Name:</label> | |
<input type="text" class="form-control" id="name" required> | |
</div> | |
<div class="form-group"> | |
<label for="powerRequired">Power Required:</label> | |
<input type="number" class="form-control" id="powerRequired" required> | |
</div> | |
<div class="form-group"> | |
<label for="rfidTag">RFID Tag:</label> | |
<input type="text" class="form-control" id="rfidTag" required> | |
</div> | |
<div class="form-group"> | |
<label for="locationLat">Location Latitude:</label> | |
<input type="number" step="any" class="form-control" id="locationLat" required> | |
</div> | |
<div class="form-group"> | |
<label for="locationLong">Location Longitude:</label> | |
<input type="number" step="any" class="form-control" id="locationLong" required> | |
</div> | |
<button type="submit" class="btn btn-primary">Create Pole</button> | |
</form> | |
<div id="responseMessage" class="mt-3"></div> | |
</div> | |
<script> | |
$('#createPoleForm').on('submit', function(e) { | |
e.preventDefault(); | |
const poleData = { | |
name: $('#name').val(), | |
powerRequired: $('#powerRequired').val(), | |
rfidTag: $('#rfidTag').val(), | |
locationLat: $('#locationLat').val(), | |
locationLong: $('#locationLong').val(), | |
}; | |
$.ajax({ | |
url: 'http://localhost:5000/create_pole', // Flask API endpoint | |
type: 'POST', | |
contentType: 'application/json', | |
data: JSON.stringify(poleData), | |
success: function(response) { | |
$('#responseMessage').html('<div class="alert alert-success">Pole record created successfully!</div>'); | |
}, | |
error: function(error) { | |
$('#responseMessage').html('<div class="alert alert-danger">Failed to create pole record!</div>'); | |
} | |
}); | |
}); | |
</script> | |
</body> | |
</html> | |