0.0.1 • Published 3 years ago

http-plus-static v0.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

Serving static files for core http module

example

'use strict';
const port = 3000;
const http = require('http');
const url = require('url');
const Static = require('http-plus-static');
const app = http.createServer((req, res) => {
	let uri = url.parse(req.url, true);
	let file = new RegExp(/^\/static\/(.*)$/);
	if(uri.pathname.match(file)){
		Static.serve(req, res);
	}
	else{
		res.writeHead(200, {'Content-Type' : 'text/html'});
		res.end('Static files page.')
	}
});

app.listen(port, () => {
	console.log(`Server Up On Port => ${port}.`);
});
0.0.1

3 years ago