create new api for drawing random marks
This commit is contained in:
@@ -14,16 +14,29 @@ const aiEvaluateImageToStar = async (req, res) => {
|
||||
const formData = new FormData();
|
||||
formData.append('image', screenShot);
|
||||
|
||||
const screenshotUploadResponse = await axios.post('https://teachertrainingchennai.in/api/uploadBase64/', formData, {
|
||||
headers: {
|
||||
...formData.getHeaders(),
|
||||
},
|
||||
httpsAgent: new (require('https').Agent)({
|
||||
rejectUnauthorized: false
|
||||
})
|
||||
});
|
||||
let screenshotUrl;
|
||||
try {
|
||||
const screenshotUploadResponse = await axios.post('https://teachertrainingchennai.in/api/uploadBase64/', formData, {
|
||||
headers: {
|
||||
...formData.getHeaders(),
|
||||
},
|
||||
httpsAgent: new (require('https').Agent)({
|
||||
rejectUnauthorized: false
|
||||
})
|
||||
});
|
||||
|
||||
const screenshotUrl = screenshotUploadResponse.data.filePath;
|
||||
console.log('Screenshot upload response:', screenshotUploadResponse.data);
|
||||
screenshotUrl = screenshotUploadResponse.data.filePath;
|
||||
|
||||
if (!screenshotUrl) {
|
||||
console.error('No screenshot URL returned from upload service');
|
||||
return res.status(500).json({ error: 'Failed to upload screenshot' });
|
||||
}
|
||||
} catch (uploadError) {
|
||||
console.error('Screenshot upload error:', uploadError.message);
|
||||
return res.status(500).json({ error: 'Failed to upload screenshot: ' + uploadError.message });
|
||||
}
|
||||
|
||||
// Generate random score between 1 to 10
|
||||
const randomScore = Math.floor(Math.random() * 10) + 1; // 1-10 range
|
||||
|
||||
|
||||
Reference in New Issue
Block a user