File tree 3 files changed +13
-79
lines changed
3 files changed +13
-79
lines changed Original file line number Diff line number Diff line change 1
1
node_modules
2
- .DS_Store
2
+ .DS_Store
3
+ respostas.json
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -8,12 +8,23 @@ app.use(cors());
8
8
app . use ( express . json ( ) ) ;
9
9
10
10
const caminhoArquivo = path . join ( __dirname , 'respostas.json' ) ;
11
+ const arquivoHome = path . join ( __dirname , 'Home.html' ) ;
11
12
12
13
// Cria o arquivo se não existir
13
14
if ( ! fs . existsSync ( caminhoArquivo ) ) {
14
15
fs . writeFileSync ( caminhoArquivo , '[]' ) ;
15
16
}
16
17
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
+
17
28
// ROTA POST - Salvar nova resposta
18
29
app . post ( '/api/respostas' , ( req , res ) => {
19
30
const novaResposta = {
You can’t perform that action at this time.
0 commit comments