Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // include modules
- var sys = require('sys')
- var express = require('express'),
- app = express(),
- path = require('path'),
- less = require('less-middleware');
- var mongodb = require('mongodb');
- var exec = require('child_process').exec;
- //We need to work with "MongoClient" interface in order to connect to a mongodb server.
- var MongoClient = mongodb.MongoClient;
- // Connection URL. This is where your mongodb server is running.
- var url = 'mongodb://localhost:27017/cwi';
- // Use connect method to connect to the Server
- MongoClient.connect(url, function (err, db) {
- if (err) {
- console.log('Unable to connect to the mongoDB server. Error:', err);
- } else {
- //HURRAY!! We are connected. :)
- console.log('Connection established to', url);
- // do some work here with the database.
- //Close connection
- }
- });
- // compile and serve css
- app.use(less(path.join(__dirname,'source','less'),{
- dest: path.join(__dirname, 'public'),
- options: {
- compiler: {
- compress: false,
- },
- },
- preprocess: {
- path: function(pathname, req) {
- return pathname.replace('/css/','/');
- },
- },
- force: true,
- }));
- // serve static content
- app.use(express.static(path.join(__dirname, 'public')));
- // setup server
- var server = app.listen(1337);
- console.log("Server Started");
- function puts(error, stdout, stderr) {sys.puts(stdout)}
- // exec("BitBeand getinfo", console.log);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement