Skip to content

Commit 72bd711

Browse files
save file
1 parent 244392e commit 72bd711

File tree

1 file changed

+5
-10
lines changed
  • blog/25-07-24/http-server/ex

1 file changed

+5
-10
lines changed

blog/25-07-24/http-server/ex/ex1.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717

1818
function request(req,res){
19-
19+
console.log(req.method,req.url);
2020
if(cors(req,res)){
2121
return;
2222
}
@@ -67,7 +67,7 @@
6767
if(req.method!='OPTIONS'){
6868
return;
6969
}
70-
70+
console.log('cors');
7171
res.writeHead(200);
7272
res.end();
7373
return true;
@@ -86,15 +86,15 @@
8686

8787

8888
function badrequest(req,res){
89-
89+
console.log('bad request');
9090
res.writeHead(400);
9191
res.end(`${req.url} bad request`);
9292

9393
}//bad
9494

9595

9696
function notfound(req,res){
97-
97+
console.log('not found');
9898
res.writeHead(400);
9999
res.end(`${req.url} not found`);
100100

@@ -165,12 +165,7 @@
165165

166166
function mime(fn){
167167

168-
var ext = fn;
169-
var i = fn.lastIndexOf('.');
170-
if(i!=-1){
171-
ext = fn.slice(i+1);
172-
}
173-
168+
var ext = fn.split('.').at(-1);
174169
switch(ext){
175170

176171
case 'html' : return 'text/html';

0 commit comments

Comments
 (0)