Advertisement
therelic

Untitled

Jan 21st, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. // include modules
  2. var sys = require('sys')
  3. var express = require('express'),
  4. app = express(),
  5. path = require('path'),
  6. less = require('less-middleware');
  7.  
  8. var mongodb = require('mongodb');
  9. var exec = require('child_process').exec;
  10.  
  11. //We need to work with "MongoClient" interface in order to connect to a mongodb server.
  12. var MongoClient = mongodb.MongoClient;
  13.  
  14. // Connection URL. This is where your mongodb server is running.
  15. var url = 'mongodb://localhost:27017/cwi';
  16.  
  17. // Use connect method to connect to the Server
  18. MongoClient.connect(url, function (err, db) {
  19. if (err) {
  20. console.log('Unable to connect to the mongoDB server. Error:', err);
  21. } else {
  22. //HURRAY!! We are connected. :)
  23. console.log('Connection established to', url);
  24.  
  25. // do some work here with the database.
  26.  
  27. //Close connection
  28. }
  29. });
  30.  
  31. // compile and serve css
  32. app.use(less(path.join(__dirname,'source','less'),{
  33. dest: path.join(__dirname, 'public'),
  34. options: {
  35. compiler: {
  36. compress: false,
  37. },
  38. },
  39. preprocess: {
  40. path: function(pathname, req) {
  41. return pathname.replace('/css/','/');
  42. },
  43. },
  44. force: true,
  45. }));
  46.  
  47. // serve static content
  48. app.use(express.static(path.join(__dirname, 'public')));
  49.  
  50. // setup server
  51. var server = app.listen(1337);
  52. console.log("Server Started");
  53.  
  54. function puts(error, stdout, stderr) {sys.puts(stdout)}
  55. // exec("BitBeand getinfo", console.log);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement