This commit is contained in:
dzikafoczka 2024-12-21 22:11:47 +01:00
parent fa5cc38d44
commit 4250458b60
2 changed files with 88 additions and 0 deletions

31
scripts.js Normal file
View File

@ -0,0 +1,31 @@
document.getElementById('uploadForm').addEventListener('submit', function (event) {
event.preventDefault();
const fileInput = document.getElementById('file');
const file = fileInput.files[0];
if (file) {
const formData = new FormData();
formData.append('file', file);
fetch('http://127.0.0.1/invoice', {
method: 'POST',
body: formData,
})
.then(response => response.json())
.then(data => {
document.getElementById('responseMessage').innerHTML = `
<p>Plik zosta³ pomyœlnie przes³any!</p>
<pre>${{JSON.stringify(data, null, 2)}}</pre>
`;
})
.catch(error => {
document.getElementById('responseMessage').innerHTML = `
<p>B³¹d podczas przesy³ania pliku: ${error.message}</p>
`;
});
} else {
alert('Proszê wybraæ plik!');
}
});

57
styles.css Normal file
View File

@ -0,0 +1,57 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.container {
background-color: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
text-align: center;
width: 100%;
max-width: 400px;
}
h1 {
margin-bottom: 20px;
}
form {
display: flex;
flex-direction: column;
}
input[type="file"] {
margin-bottom: 10px;
padding: 8px;
}
button {
padding: 10px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
font-size: 16px;
border-radius: 4px;
}
button:hover {
background-color: #45a049;
}
#responseMessage {
margin-top: 20px;
font-size: 16px;
}