create new api for drawing random marks
This commit is contained in:
@@ -10,32 +10,18 @@ const aiEvaluateImageToStar = async (req, res) => {
|
||||
return res.status(400).json({ error: 'Screenshot is required' });
|
||||
}
|
||||
|
||||
// Upload screenshot
|
||||
// Upload screenshot
|
||||
const formData = new FormData();
|
||||
formData.append('image', screenShot);
|
||||
|
||||
let screenshotUrl = null;
|
||||
try {
|
||||
const screenshotUploadResponse = await axios.post('https://teachertrainingchennai.in/api/uploadBase64/', formData, {
|
||||
headers: {
|
||||
...formData.getHeaders(),
|
||||
},
|
||||
httpsAgent: new (require('https').Agent)({
|
||||
rejectUnauthorized: false
|
||||
})
|
||||
});
|
||||
const screenshotUploadResponse = await axios.post('https://teachertrainingchennai.in/api/uploadBase64/', formData, {
|
||||
headers: {
|
||||
...formData.getHeaders(),
|
||||
},
|
||||
});
|
||||
|
||||
console.log('Screenshot upload response:', screenshotUploadResponse.data);
|
||||
|
||||
// Check if response is JSON and has filePath
|
||||
if (screenshotUploadResponse.data && typeof screenshotUploadResponse.data === 'object' && screenshotUploadResponse.data.filePath) {
|
||||
screenshotUrl = screenshotUploadResponse.data.filePath;
|
||||
} else {
|
||||
console.log('Upload service did not return valid JSON with filePath, continuing without upload');
|
||||
}
|
||||
} catch (uploadError) {
|
||||
console.log('Screenshot upload failed, continuing without upload:', uploadError.message);
|
||||
}
|
||||
const screenshotUrl = screenshotUploadResponse.data.filePath;
|
||||
|
||||
// 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