Asanaly commited on
Commit
3fe73a4
·
verified ·
1 Parent(s): 1978944

Create script.js

Browse files
Files changed (1) hide show
  1. script.js +28 -0
script.js ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const API = window.location.origin.replace("http", "http") + ":7860";
2
+
3
+ async function summarizeText() {
4
+ const text = document.getElementById("inputText").value;
5
+
6
+ const response = await fetch(API + "/summarize/text", {
7
+ method: "POST",
8
+ headers: { "Content-Type": "application/json" },
9
+ body: JSON.stringify({ text })
10
+ });
11
+
12
+ const data = await response.json();
13
+ document.getElementById("output").innerText = data.summary;
14
+ }
15
+
16
+ async function summarizePDF() {
17
+ const file = document.getElementById("pdfInput").files[0];
18
+ const formData = new FormData();
19
+ formData.append("file", file);
20
+
21
+ const response = await fetch(API + "/summarize/pdf", {
22
+ method: "POST",
23
+ body: formData
24
+ });
25
+
26
+ const data = await response.json();
27
+ document.getElementById("output").innerText = data.summary;
28
+ }