51 lines
1.1 KiB
HTML
51 lines
1.1 KiB
HTML
{% extends 'base.html' %}
|
|
|
|
{% block title %}
|
|
| Sistemas
|
|
{% endblock title %}
|
|
|
|
|
|
{% block content %}
|
|
<form id="upload-form">
|
|
<input type="file" name="zip_file">
|
|
<button type="submit">Upload</button>
|
|
</form>
|
|
<input type="hidden" id="id_token" name="token" value="{{ token }}">
|
|
{% endblock content %}
|
|
|
|
|
|
|
|
{% block scripts %}
|
|
<script>
|
|
|
|
document.getElementById('upload-form').addEventListener('submit', function (event) {
|
|
event.preventDefault();
|
|
let formData = new FormData(event.target);
|
|
let token = document.getElementById("id_token").value;
|
|
fetch(`{% url 'uploadZip' %}`, {
|
|
method: 'POST',
|
|
body: formData,
|
|
headers: {
|
|
'Authorization': 'Token ' + token,
|
|
},
|
|
})
|
|
.then(function (response) {
|
|
if (!response.ok) {
|
|
throw new Error('Network response was not ok');
|
|
}
|
|
return response.json();
|
|
})
|
|
.then(function (data) {
|
|
console.log(data);
|
|
window.location.reload();
|
|
})
|
|
.catch(function (error) {
|
|
console.error(error);
|
|
});
|
|
});
|
|
|
|
|
|
</script>
|
|
|
|
{% endblock scripts %}
|
|
|