http-plus-static

0.0.1 • Public • Published

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}.`);
});

Package Sidebar

Install

npm i http-plus-static

Weekly Downloads

1

Version

0.0.1

License

ISC

Unpacked Size

2.76 kB

Total Files

6

Last publish

Collaborators

  • imcatur