anycoder-5eb157c9 / pages /api /contact.js
ColdSlim's picture
Upload pages/api/contact.js with huggingface_hub
583626c verified
raw
history blame contribute delete
672 Bytes
export default function handler(req, res) {
if (req.method === 'POST') {
const { name, email, message } = req.body;
// Basic validation
if (!name || !email || !message) {
return res.status(400).json({ error: 'Missing required fields' });
}
// In a real app, you would save this to a database or send an email
console.log('Contact Form Submission:', { name, email, message });
// Simulate network delay
setTimeout(() => {
res.status(200).json({ message: 'Transmission received successfully' });
}, 1000);
} else {
res.setHeader('Allow', ['POST']);
res.status(405).end(`Method ${req.method} Not Allowed`);
}
}