Skip to content

Commit 846b37d

Browse files
authored
Create servidor.js
1 parent d3f9bcd commit 846b37d

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

servidor.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// servidor.js
2+
// Servidor básico em Node.js usando Express para servir arquivos estáticos (index.html, style.css, script.js)
3+
4+
const express = require('express');
5+
const path = require('path');
6+
7+
const app = express();
8+
const PORT = process.env.PORT || 3000;
9+
10+
// Define a pasta de arquivos estáticos (onde estão index.html, style.css, script.js)
11+
app.use(express.static(path.join(__dirname, '.')));
12+
13+
// Rota padrão para servir index.html
14+
app.get('/', (req, res) => {
15+
res.sendFile(path.join(__dirname, 'index.html'));
16+
});
17+
18+
// Inicia o servidor
19+
app.listen(PORT, () => {
20+
console.log(`Servidor rodando em http://localhost:${PORT}`);
21+
});

0 commit comments

Comments
 (0)