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

integrated deployed API #16

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions src/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ const Header = () => {
return (
<HeaderWrapper>
<div>
<Link to={`/`}>
<BrandName><img style={{width: "32px", height: "32px", marginRight: "16px"}} src="https://emoji.slack-edge.com/T5Y8VC3HU/copilot/b9f707d326122736.png" alt="brand-name"/>SELF</BrandName>
</Link>
</div>
{true && (
<div>
Expand Down
40 changes: 18 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,24 +87,20 @@ 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(
"https://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);
setLoading(false);
} catch (error) {
console.error("Error summarizing text:", error);
setLoading(false);
Expand Down Expand Up @@ -135,7 +131,7 @@ const PDFAssetPage = () => {
id="summary"
placeholder="PDF Summary here..."
style={{
width: "800px",
width: "70%",
height: "150px",
fontSize: "18px",
fontFamily: "serif",
Expand Down
Loading