Initial commit: added frontend and backend

This commit is contained in:
2026-09-22 12:02:38 +05:30
commit cd2770e590
154 changed files with 25892 additions and 0 deletions
+56
View File
@@ -0,0 +1,56 @@
const axios = require('axios');
const FormData = require('form-data');
exports.analyzeImage = async (req, res) => {
try {
if (!req.file) {
return res.status(400).json({ error: 'No image provided' });
}
// In a real scenario, we would forward this to the Perfect Corp API
// For now, we will return a mock response matching the expected structure
// or you could proxy it like this:
/*
const formData = new FormData();
formData.append('image', req.file.buffer, req.file.originalname);
const response = await axios.post(process.env.PERFECT_CORP_API_URL, formData, {
headers: {
...formData.getHeaders(),
'Authorization': `Bearer ${process.env.PERFECT_CORP_API_KEY}`
}
});
return res.json({ result: response.data });
*/
// MOCK RESPONSE
console.log('Mocking perfect corp analysis for image:', req.file.originalname);
const mockResult = {
results: [
{
data: [
{
url: 'https://example.com/mock-mask.zip'
}
]
}
],
// Add other mock data that the frontend expects to parse...
face_attributes: {
age: 30,
gender: 'female'
},
skin_issues: {
wrinkles: 10,
spots: 5,
acne: 2
}
};
res.json({ result: mockResult });
} catch (error) {
console.error('Error analyzing image:', error);
res.status(500).json({ error: 'Failed to analyze image' });
}
};