Socket
Socket
Sign inDemoInstall

005-http-open

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.0.1

tool.js

34

index.js

@@ -7,11 +7,31 @@ #!/usr/bin/env node

const path=require('path');
const query=require('querystring');
const child=require('child_process');
const getaddress=require('./getaddress')
const port=3000;
const tool=require('./tool')
const port=8000;
const server=http.createServer((req,res)=>{
let ws=fs.createReadStream(path.join(__dirname,'index.html'))
ws.pipe(res);
ws.on('end',()=>{
let file=path.resolve(path.join('.',query.unescape(req.url)));
if(fs.existsSync(file)){
if(tool.isfile(file)){
fs.readFile(file,(err,data)=>{
res.end(data)
})
}else if(tool.isdir(file)){
let lis='';
fs.readdirSync(file).forEach(v=>{
lis+= `
<li>
<a href=${path.join(query.unescape(req.url),v)}>
${v+(tool.isdir(path.join(file,v))?'/':'')}
</a>
</li>
`
})
let html= fs.readFileSync(path.join(__dirname,'index.html')).toString();
res.end(html.replace("$",lis));
}
}else{
res.writeHead(404);
res.end();
})
}
})

@@ -21,5 +41,5 @@ server.listen(port,()=>{

protocol:'http',
hostname:getaddress(),
hostname:tool.getaddress(),
port:port
})])
})
{
"name": "005-http-open",
"version": "1.0.0",
"version": "1.0.1",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc