daily pastebin goal
70%
SHARE
TWEET

Untitled

a guest Dec 16th, 2018 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // required
  2. var express = require('express');
  3. var path = require('path');
  4. var mongoose = require('mongoose');
  5. var config = require('./config/database');
  6.  
  7. // koneksi ke database
  8. mongoose.connect(config.database, { useNewUrlParser: true });
  9.  
  10. var db = mongoose.connection;
  11. db.on('error', console.error.bind(console, 'connection error:'));
  12. db.once('open', function() {
  13.     // We're connected
  14.     console.log('Horrreeee bisa konek ke MongoDB');
  15. });
  16.  
  17. // Initial app
  18. var app = express();
  19.  
  20. // setup View menggunakan engine ejs
  21. app.set('views', path.join(__dirname, 'views'));
  22. app.set('view engine', 'ejs');
  23.  
  24. // setup public folder
  25. app.use(express.static(path.join(__dirname, 'public'))
  26. );
  27.  
  28. // setup halaman index
  29. app.get('/', function(req, res) {
  30.     res.render('index', {
  31.         title: "Home"
  32.     });
  33. });
  34.  
  35.  
  36.  
  37. // setup server
  38. var port = 3000;
  39. app.listen(port, function() {
  40.     console.log("Server running on port " + port);
  41. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top