Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using deployed server in app #15

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading