This repository was archived by the owner on Mar 10, 2025. It is now read-only.
File tree 2 files changed +34
-0
lines changed
2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -1045,6 +1045,8 @@ <h2 class=" footer-col-title">contact information</h2>
1045
1045
<!-- For img gen -->
1046
1046
< script src ="js/Teacher.js "> </ script >
1047
1047
< script src ="js/GenImage.js "> </ script >
1048
+ < script src ="sendText.js "> </ script >
1049
+
1048
1050
</ body >
1049
1051
1050
1052
</ html >
Original file line number Diff line number Diff line change
1
+ document . addEventListener ( "DOMContentLoaded" , ( ) => {
2
+ const askButton = document . getElementById ( "ask" ) ;
3
+ const questionInput = document . getElementById ( "question" ) ;
4
+
5
+ askButton . addEventListener ( "click" , ( ) => {
6
+ const text = questionInput . value ;
7
+ if ( text . trim ( ) !== "" ) {
8
+ // Send the user's input to the server
9
+ sendTextToServer ( text ) ;
10
+ } else {
11
+ alert ( "Please enter a question." ) ;
12
+ }
13
+ } ) ;
14
+
15
+ function sendTextToServer ( text ) {
16
+ fetch ( "/synthesize" , {
17
+ method : "POST" ,
18
+ headers : {
19
+ "Content-Type" : "application/json" ,
20
+ } ,
21
+ body : JSON . stringify ( { text : text } ) ,
22
+ } )
23
+ . then ( ( response ) => response . text ( ) )
24
+ . then ( ( data ) => {
25
+ console . log ( data ) ; // Log the server's response
26
+ } )
27
+ . catch ( ( error ) => {
28
+ console . error ( "Error:" , error ) ;
29
+ } ) ;
30
+ }
31
+ } ) ;
32
+
You can’t perform that action at this time.
0 commit comments