Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
AI Tutor
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Salma Mohammed Hamed
AI Tutor
Commits
8d42c50c
Commit
8d42c50c
authored
Oct 26, 2025
by
SalmaMohammedHamedMustafa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
edit in the curriculum_PDF_uploader.html
parent
ae47fc46
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
51 deletions
+53
-51
curriculum_PDF_uploader.html
...osted_env/voice_agent/static/curriculum_PDF_uploader.html
+53
-51
No files found.
self_hosted_env/voice_agent/static/curriculum_PDF_uploader.html
View file @
8d42c50c
...
@@ -105,68 +105,70 @@
...
@@ -105,68 +105,70 @@
<pre
id=
"response"
style=
"display:none;"
></pre>
<pre
id=
"response"
style=
"display:none;"
></pre>
</div>
</div>
<script>
<script>
const
API_URL
=
'http://localhost:8000/process-curriculum'
;
// The API_URL constant is no longer needed and has been removed.
const
pdfFileInput
=
document
.
getElementById
(
'pdfFile'
);
const
pdfFileInput
=
document
.
getElementById
(
'pdfFile'
);
const
uploadButton
=
document
.
getElementById
(
'uploadButton'
);
const
uploadButton
=
document
.
getElementById
(
'uploadButton'
);
const
statusDiv
=
document
.
getElementById
(
'status'
);
const
statusDiv
=
document
.
getElementById
(
'status'
);
const
responsePre
=
document
.
getElementById
(
'response'
);
const
responsePre
=
document
.
getElementById
(
'response'
);
const
gradeInput
=
document
.
getElementById
(
'gradeInput'
);
const
gradeInput
=
document
.
getElementById
(
'gradeInput'
);
const
subjectInput
=
document
.
getElementById
(
'subjectInput'
);
//
<--
Get
the
new
subject
field
const
subjectInput
=
document
.
getElementById
(
'subjectInput'
);
uploadButton
.
addEventListener
(
'click'
,
async
()
=>
{
uploadButton
.
addEventListener
(
'click'
,
async
()
=>
{
const
selectedFile
=
pdfFileInput
.
files
[
0
];
const
selectedFile
=
pdfFileInput
.
files
[
0
];
const
grade
=
gradeInput
.
value
;
const
grade
=
gradeInput
.
value
;
const
subject
=
subjectInput
.
value
;
//
<--
Get
the
subject
value
const
subject
=
subjectInput
.
value
;
// --- Update validation ---
if
(
!
selectedFile
)
{
showStatus
(
'Please select a PDF file first.'
,
'error'
);
return
;
}
if
(
!
selectedFile
)
{
showStatus
(
'Please select a PDF file first.'
,
'error'
);
return
;
}
if
(
!
grade
)
{
showStatus
(
'Please enter a grade.'
,
'error'
);
return
;
}
if
(
!
grade
)
{
showStatus
(
'Please enter a grade.'
,
'error'
);
return
;
}
if
(
!
subject
)
{
showStatus
(
'Please enter a subject.'
,
'error'
);
return
;
}
if
(
!
subject
)
{
showStatus
(
'Please enter a subject.'
,
'error'
);
return
;
}
const
formData
=
new
FormData
();
const
formData
=
new
FormData
();
formData
.
append
(
'file'
,
selectedFile
);
formData
.
append
(
'file'
,
selectedFile
);
formData
.
append
(
'grade'
,
grade
);
formData
.
append
(
'grade'
,
grade
);
formData
.
append
(
'subject'
,
subject
);
formData
.
append
(
'subject'
,
subject
);
// 3. Update UI to show processing state
showStatus
(
'Uploading and starting background processing...'
,
'processing'
);
showStatus
(
'Uploading and starting background processing...'
,
'processing'
);
uploadButton
.
disabled
=
true
;
uploadButton
.
disabled
=
true
;
responsePre
.
style
.
display
=
'none'
;
responsePre
.
style
.
display
=
'none'
;
try
{
try
{
// 4. Send the file AND grade to the API
// --- THIS IS THE FIX ---
const
response
=
await
fetch
(
API_URL
,
{
// We now `await` the fetch call and assign its result to `response`.
method
:
'POST'
,
const
response
=
await
fetch
(
'/process-curriculum'
,
{
body
:
formData
,
method
:
'POST'
,
});
body
:
formData
,
});
const
responseData
=
await
response
.
json
();
// This line can now work correctly because the 'response' variable exists.
const
responseData
=
await
response
.
json
();
// 5. Handle the server's response
if
(
!
response
.
ok
)
{
if
(
!
response
.
ok
)
{
throw
new
Error
(
responseData
.
detail
||
`Server error:
${
response
.
statusText
}
`
);
throw
new
Error
(
responseData
.
detail
||
`Server error:
${
response
.
statusText
}
`
);
}
showStatus
(
'Success! The server has started processing your file in the background.'
,
'success'
);
responsePre
.
textContent
=
JSON
.
stringify
(
responseData
,
null
,
2
);
responsePre
.
style
.
display
=
'block'
;
}
catch
(
error
)
{
showStatus
(
`An error occurred:
${
error
.
message
}
`
,
'error'
);
}
finally
{
// 6. Re-enable the button
uploadButton
.
disabled
=
false
;
}
}
});
// Helper function to show status messages
showStatus
(
'Success! The server has started processing your file in the background.'
,
'success'
);
function
showStatus
(
message
,
type
)
{
responsePre
.
textContent
=
JSON
.
stringify
(
responseData
,
null
,
2
);
statusDiv
.
textContent
=
message
;
responsePre
.
style
.
display
=
'block'
;
statusDiv
.
className
=
`status
${
type
}
`
;
statusDiv
.
style
.
display
=
'block'
;
}
catch
(
error
)
{
// Network errors or other exceptions will be caught here.
showStatus
(
`An error occurred:
${
error
.
message
}
`
,
'error'
);
}
finally
{
uploadButton
.
disabled
=
false
;
}
}
</script>
});
// Helper function to show status messages
function
showStatus
(
message
,
type
)
{
statusDiv
.
textContent
=
message
;
statusDiv
.
className
=
`status
${
type
}
`
;
statusDiv
.
style
.
display
=
'block'
;
}
</script>
</body>
</body>
</html>
</html>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment