SHARE
TWEET

NodeJS : Render File PUG ke HTML Disertai Routing nya

stevennathaniel Jun 18th, 2016 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Created by StevenNathaniel on 18-Jun-16.
  3.  */
  4. var express = require('express')
  5. var app = express();
  6. var path = require("path");
  7. var pug = require('pug');
  8.  
  9. app.set('view engine', 'pug');
  10.  
  11. /*app.get('/', function(req, res) {
  12.     res.sendFile(path.join(__dirname + '/views/halaman1.html'));
  13. });*/
  14.  
  15. app.get('/halaman1', function(req, res) {
  16.     res.render(path.join(__dirname + '/views/halaman1.pug'));
  17. });
  18.  
  19.  
  20. var server = app.listen(3000, function() {
  21.  
  22.     var host = server.address().address
  23.     var port = server.address().port
  24.  
  25.     console.log("Aplikasi berjalan di http://%s:%s", host, port)
  26.  
  27. });
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