UNPKG

hackdoor

Version:

##

28 lines (23 loc) 692 B
const http = require('http') const path = require('path') const fs = require('fs') const conf = require('./config') const fnFile = require('./helper/file') const openUrl = require('./helper/openUrl') class Server { constructor(config) { this.conf = Object.assign({}, conf, config) } start() { const server = http.createServer((req, res) => { const filePath = path.join(this.conf.root, req.url) fnFile(req, res, filePath) }) server.listen(this.conf.port, this.conf.hostname, () => { const addr = `http://${this.conf.hostname}:${this.conf.port}` console.log(`server running in ${addr}`) openUrl(addr) }) } } module.exports = Server