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();
|
const formData = new FormData();
|
||||||
formData.append('image', screenShot);
|
formData.append('image', screenShot);
|
||||||
|
|
||||||
const screenshotUploadResponse = await axios.post('https://teachertrainingchennai.in/api/uploadBase64/', formData, {
|
let screenshotUrl;
|
||||||
headers: {
|
try {
|
||||||
...formData.getHeaders(),
|
const screenshotUploadResponse = await axios.post('https://teachertrainingchennai.in/api/uploadBase64/', formData, {
|
||||||
},
|
headers: {
|
||||||
httpsAgent: new (require('https').Agent)({
|
...formData.getHeaders(),
|
||||||
rejectUnauthorized: false
|
},
|
||||||
})
|
httpsAgent: new (require('https').Agent)({
|
||||||
});
|
rejectUnauthorized: false
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
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 });
|
||||||
|
}
|
||||||
|
|
||||||
const screenshotUrl = screenshotUploadResponse.data.filePath;
|
|
||||||
// Generate random score between 1 to 10
|
// Generate random score between 1 to 10
|
||||||
const randomScore = Math.floor(Math.random() * 10) + 1; // 1-10 range
|
const randomScore = Math.floor(Math.random() * 10) + 1; // 1-10 range
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user