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')
const bodyParser = require('body-parser')
const session = require('express-session')
const app = express()
var express = require("express");
var cookieParser = require("cookie-parser");
var logger = require("morgan");
var bodyParser = require("body-parser");
const app = express();
app.use(express.static('public'))
app.set('view engine', 'ejs')
app.use(bodyParser.urlencoded({ extended: true }));
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', ()=> {
console.log('Server sudah berjalan di port 3000')
})
app.use("/", indexRouter);
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;