From c6d025bc7a608d3ed9c022bd502e6f9bc49a865d Mon Sep 17 00:00:00 2001 From: ParamPatil <62197336+parampatil@users.noreply.github.com> Date: Sun, 14 Apr 2024 18:01:36 -0400 Subject: [PATCH] Working --- src/Components/Spinner.jsx | 24 ++++++++++++++++++++++ src/Components/spinner.css | 33 ++++++++++++++++++++++++++++++ src/pages/FileUploadComponent .jsx | 19 ++++++++--------- 3 files changed, 66 insertions(+), 10 deletions(-) create mode 100644 src/Components/Spinner.jsx create mode 100644 src/Components/spinner.css diff --git a/src/Components/Spinner.jsx b/src/Components/Spinner.jsx new file mode 100644 index 0000000..037fce3 --- /dev/null +++ b/src/Components/Spinner.jsx @@ -0,0 +1,24 @@ +import './spinner.css'; + +const Spinner = () => ( + + + + ); + + export default Spinner; + \ No newline at end of file diff --git a/src/Components/spinner.css b/src/Components/spinner.css new file mode 100644 index 0000000..51d51a9 --- /dev/null +++ b/src/Components/spinner.css @@ -0,0 +1,33 @@ +.spinner { + animation: rotate 1s linear infinite; + width: 50px; + height: 50px; + } + + .path { + stroke: #333; + stroke-linecap: round; + animation: dash 1.5s ease-in-out infinite; + } + + @keyframes rotate { + 100% { + transform: rotate(360deg); + } + } + + @keyframes dash { + 0% { + stroke-dasharray: 1, 150; + stroke-dashoffset: 0; + } + 50% { + stroke-dasharray: 90, 150; + stroke-dashoffset: -35; + } + 100% { + stroke-dasharray: 90, 150; + stroke-dashoffset: -124; + } + } + \ No newline at end of file diff --git a/src/pages/FileUploadComponent .jsx b/src/pages/FileUploadComponent .jsx index 5e67295..23590b1 100644 --- a/src/pages/FileUploadComponent .jsx +++ b/src/pages/FileUploadComponent .jsx @@ -46,21 +46,20 @@ const FileUploadComponent = () => { const handleSplitAndDownload = async () => { try { - const response = await axios.post( - "http://manavmandal.pythonanywhere.com/split", - { file: selectedFile }, - { - responseType: "blob", - } - ); + // Trigger the split URL with a GET request + const response = await axios.get("http://manavmandal.pythonanywhere.com/split", { + responseType: "blob", // Receive response as a blob (binary data) + }); + // Create a download URL for the received blob const downloadUrl = window.URL.createObjectURL(new Blob([response.data])); + // Create a download link element const downloadLink = document.createElement("a"); downloadLink.href = downloadUrl; - downloadLink.setAttribute("download", "split_files.zip"); + downloadLink.setAttribute("download", "split_files.zip"); // Set download attribute and file name document.body.appendChild(downloadLink); - downloadLink.click(); - document.body.removeChild(downloadLink); + downloadLink.click(); // Simulate click to trigger download + document.body.removeChild(downloadLink); // Remove the download link element after download } catch (error) { console.error("Split and download failed:", error); }