-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #540 from Ojas-Arora/test
Improve Backend of Contact Page
- Loading branch information
Showing
5 changed files
with
117 additions
and
29 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const express = require('express'); | ||
const cors = require('cors'); | ||
const multer = require('multer'); | ||
|
||
const app = express(); | ||
const port = 3000; | ||
|
||
// Use CORS to allow requests from the frontend | ||
app.use(cors()); | ||
|
||
// Set up multer for handling file uploads | ||
const upload = multer({ dest: 'uploads/' }); | ||
|
||
app.post('/send', upload.single('attachments'), (req, res) => { | ||
const { name, email, issue, message } = req.body; | ||
const attachment = req.file; | ||
|
||
console.log('Received:', { name, email, issue, message, attachment }); | ||
|
||
// Simulate processing the data | ||
if (name && email && issue && message) { | ||
res.json({ success: true }); | ||
} else { | ||
res.json({ success: false }); | ||
} | ||
}); | ||
|
||
app.listen(port, () => { | ||
console.log(`Server running at http://localhost:${port}`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters