Edited main index.js

This commit is contained in:
Matthew Patrick 2021-11-15 15:29:10 +07:00
parent 9381551dd7
commit 45eb8a05a7

View file

@ -1,15 +1,33 @@
const express = require('express') var express = require("express");
const bodyParser = require('body-parser') var cookieParser = require("cookie-parser");
const session = require('express-session') var logger = require("morgan");
const app = express() var bodyParser = require("body-parser");
const app = express();
app.use(express.static('public')) app.use(bodyParser.urlencoded({ extended: true }));
app.set('view engine', 'ejs') app.use(bodyParser.json());
app.use(logger("dev"));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
const indexRouter = require('./routes/index'); app.use(express.static("public"));
app.set("view engine", "ejs");
app.use('/', indexRouter); const indexRouter = require("./routes/index");
app.listen('3000', ()=> { app.use("/", indexRouter);
console.log('Server sudah berjalan di port 3000')
}) app.use(function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header(
"Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept"
);
next();
});
app.listen("3000", () => {
console.log("Server is running on port : 3000");
});
module.exports = app;