forked from torome/angular-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
31 lines (23 loc) · 750 Bytes
/
Copy pathserver.js
File metadata and controls
31 lines (23 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
var express = require('express') ;
var http = require('http');
var auth=require('./auth');
var book=require('./book');
var app=express();
app.configure(function () {
app.use(express.cookieParser());
app.use(express.bodyParser());
app.use('/public', express.static(__dirname + '/public'));
app.use(express.errorHandler());
});
app.get('/', auth.checkAuth, function(req,res){
res.sendfile(__dirname+'/public/index.html');
});
app.get('/login', function(req,res){
res.sendfile(__dirname+'/public/login.html');
});
app.post('/user/login', auth.login);
app.post('/user/logout', auth.logout);
app.get('/book', book.findAll);
app.post('/book', book.add);
http.createServer(app).listen(3000);
console.log("server listening on port 3000");