Index routing done

This commit is contained in:
2022-05-30 14:21:52 -03:00
parent d796c9ed5e
commit 7e08e5a5b5
4 changed files with 25 additions and 15 deletions

View File

@@ -1,11 +0,0 @@
const Express = require("express")
const server = Express()
const port = 3000
server.get("/", (req, res) => {
res.send("TEST")
})
server.listen(port)
console.log("Listening in the port ", port)

10
src/routes/index.js Normal file
View File

@@ -0,0 +1,10 @@
const express = require('express')
const router = express.Router()
const path = require('path');
router.get("/", (req, res) => {
res.sendFile(path.resolve('public/index.html'));
})
module.exports = router

10
src/server.js Normal file
View File

@@ -0,0 +1,10 @@
const express = require("express")
const server = express()
const port = 3000
const index = require('./routes/index.js')
server.use("/", index)
server.listen(port)
console.log("Listening in the port ", port)