-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtute8.js
More file actions
27 lines (23 loc) · 704 Bytes
/
Copy pathtute8.js
File metadata and controls
27 lines (23 loc) · 704 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
// JavaScript Document
var express= require('express');
var app =express();
var fs=require('fs');
var path =require('path');
app.use('/mycssfiles',express.static(__dirname+'/css'));
app.get("/",function(request,response){
response.sendFile('home.html',{root:__dirname});
});
app.get(/^(.+)/,function(request,response){
// response.end(JSON.stringify(request.query));
try{
if(fs.statSync(path.join(__dirname,'views',request.params[0]+'.html'))){
responce.sendFile(request.params[0]+'.html',{root:path.join(__dirname,'views')});
}
}
catch(error){
responce.sendFile('404.html',{root:path.join(__dirname,'views')});
}
});
app.listen(8080,function(){
console.log("server is up");
});