Skip to content

Commit 439813e

Browse files
authored
Merge pull request #1 from Tabsber/fix/home-from-js
Fix/home from js
2 parents dd85cc2 + 88aa82e commit 439813e

File tree

3 files changed

+13
-79
lines changed

3 files changed

+13
-79
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
2-
.DS_Store
2+
.DS_Store
3+
respostas.json

respostas.json

-78
This file was deleted.

salvar.js

+11
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,23 @@ app.use(cors());
88
app.use(express.json());
99

1010
const caminhoArquivo = path.join(__dirname, 'respostas.json');
11+
const arquivoHome = path.join(__dirname, 'Home.html');
1112

1213
// Cria o arquivo se não existir
1314
if (!fs.existsSync(caminhoArquivo)) {
1415
fs.writeFileSync(caminhoArquivo, '[]');
1516
}
1617

18+
app.get('/', (req, res) => {
19+
try {
20+
const conteudo = fs.readFileSync(arquivoHome, 'utf8');
21+
res.send(conteudo);
22+
} catch (err) {
23+
console.error('Error reading the file:', err);
24+
res.status(500).send('Internal Server Error');
25+
}
26+
});
27+
1728
// ROTA POST - Salvar nova resposta
1829
app.post('/api/respostas', (req, res) => {
1930
const novaResposta = {

0 commit comments

Comments
 (0)