Skip to content

Commit 6049850

Browse files
authored
Create Servidor.js
1 parent f212dfa commit 6049850

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

HTML/Servidor.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const express = require('express');
2+
const bodyParser = require('body-parser');
3+
const app = express();
4+
const port = 3000;
5+
6+
// Middleware
7+
app.use(bodyParser.json());
8+
app.use(express.static('public'));
9+
10+
// Endpoints
11+
app.get('/', (req, res) => {
12+
res.sendFile(__dirname + '/public/index.html');
13+
});
14+
15+
app.post('/api/contact', (req, res) => {
16+
const { name, email, message } = req.body;
17+
console.log(`Received contact form submission:
18+
Name: ${name}
19+
Email: ${email}
20+
Message: ${message}`);
21+
res.json({ status: 'success', message: 'Form submitted successfully' });
22+
});
23+
24+
// Start the server
25+
app.listen(port, () => {
26+
console.log(`Server is running at http://localhost:${port}`);
27+
});

0 commit comments

Comments
 (0)