Advertisement
Guest User

Untitled

a guest
Sep 25th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. 'use strict';
  2.  
  3. var express = require('express');
  4. var app = express();
  5. var auth = require('http-auth');
  6.  
  7. app.use(express.static('www'));
  8.  
  9. var basic = auth.basic({
  10. realm: 'SUPER SECRET STUFF'
  11. }, function(username, password, callback) {
  12. callback(username == 'username' && password == 'password');
  13. });
  14.  
  15. app.use("/", auth.connect(basic));
  16.  
  17. app.set('port', (process.env.PORT || 4000));
  18. app.listen(app.get('port'), function() {
  19. console.log('Node app is running on port', app.get('port'));
  20. });
  21.  
  22. 'use strict';
  23.  
  24. var express = require('express');
  25. var app = express();
  26. var auth = require('http-auth');
  27.  
  28. var basic = auth.basic({
  29. realm: 'SUPER SECRET STUFF'
  30. }, function(username, password, callback) {
  31. callback(username == 'username' && password == 'password');
  32. });
  33.  
  34. app.use(auth.connect(basic));
  35. app.use(express.static('www'));
  36.  
  37. app.set('port', (process.env.PORT || 4000));
  38. app.listen(app.get('port'), function() {
  39. console.log('Node app is running on port', app.get('port'));
  40. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement