Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var express = require('express');
- var path = require('path');
- var app = express();
- path = require('path'),
- index = require('./routes/index');
- app.use(express.static(path.join(__dirname, '.')));
- app.use(express.static(path.join(__dirname, 'admin_4_angularjs')));
- app.get('/', function(req, res)
- {
- res.sendFile(path.join(__dirname + '/admin_4_angularjs/index.html'));
- });
- module.exports = app;
- var port = 3000;
- app.listen(port, function()
- {
- console.log('Listening on ' + port);
- });
- // UI Bootstrap
- .state('allUsers',
- {
- url: "/allUsers.html",
- templateUrl: "views/allUsers.html",
- data:
- {
- pageTitle: 'Users List'
- },
- controller: "allUsersController",
- resolve:
- {
- allUserslist: function($http)
- {
- return $http.get("/users").then(function(response)
- {
- return response.data;
- })
- }
- }
- })
- var express = require('express');
- var mongodb = require('mongodb');
- var router = express.Router();
- var app = express();
- var MONGODB_URI = 'mongodb://xxx.xxx.1.23:27017/RELRE';
- var db;
- var coll;
- mongodb.MongoClient.connect(MONGODB_URI, function(err, database) {
- if(err) throw err;
- db = database;
- });
- router.get('/users', function(req, res) {
- var collectionInfo = db.collection("UsersInfo");
- collectionInfo.find({}).toArray(function(err, employees) {
- res.status(200).json({'myCollection' : employees});
- });
- });
- module.exports = router;
- app.get('/', function(req, res)
- {
- res.sendFile(path.join(__dirname + '/admin_4_angularjs/index.html'));
- });
- app.use(index)
- app.use('/users', index) // may also want to give the router a more meaningful name
- router.get('/', function(req, res) { // within the router, '/users' is now assumed to be the base path
- // Logic for this route
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement