Skip to content

Commit

Permalink
using deployed server in app
Browse files Browse the repository at this point in the history
  • Loading branch information
manthanraut committed May 15, 2024
1 parent 061eea6 commit 3bd6863
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions src/components/PDFAssetPage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from "react";
// import axios from "axios";
import axios from "axios";
import {
Container,
FormGroup,
Expand Down Expand Up @@ -47,7 +47,7 @@ const LoadingSpinner = () => {
};

const PDFAssetPage = () => {
// const [selectedFile, setSelectedFile] = useState(null);
const [selectedFile, setSelectedFile] = useState(null);
const [summarizedText, setSummarizedText] = useState("");
const [fileName, setFileName] = useState("");
const [fileKey, setFileKey] = useState(0);
Expand All @@ -58,7 +58,7 @@ const PDFAssetPage = () => {
};

const handleFileChange = (event) => {
// setSelectedFile(event.target.files[0]);
setSelectedFile(event.target.files[0]);
const file = event.target.files[0];
if (file) {
const fileName = file.name.replace(/\s+/g, "-");
Expand Down Expand Up @@ -87,27 +87,25 @@ const PDFAssetPage = () => {
e.preventDefault();
try {
setLoading(true);
setTimeout(() => {
const formattedText =
'The "Beginner Pilates Workout Plan" is a comprehensive guide designed for individuals new to Pilates exercises.';
setSummarizedText(formattedText);
setLoading(false);
}, 3000);
// const formData = new FormData();
// formData.append("file", selectedFile);
// const response = await axios.post(
// "http://127.0.0.1:5000/summarize",
// formData,
// {
// headers: {
// "Content-Type": "multipart/form-data",
// },
// }
// );
// const formattedText = response.data.replace(/\. /g, ".\n\n").replace(/\s+/g, " ");
const formData = new FormData();
formData.append("file", selectedFile);
const response = await axios.post(
"http://16.170.236.3:8080/summarize",
formData,
{
headers: {
"Content-Type": "multipart/form-data",
},
}
);
const formattedText = response.data
.replace(/\. /g, ".\n\n")
.replace(/\s+/g, " ");
setSummarizedText(formattedText);
} catch (error) {
console.error("Error summarizing text:", error);
setLoading(false);
} finally {
setLoading(false);
}
};

Expand Down

0 comments on commit 3bd6863

Please sign in to comment.