Skip to content
/ noype Public

An identifier for file formats transmitted on the internet

License

Notifications You must be signed in to change notification settings

kampsy/noype

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Noype is a package that helps HTTP Servers identify file formats and format content transmitted on the internet.

Installation

Put noype.js in the same dir as you server code.

Usage

A production ready HTTP Server. Not that the following code only works if noype.js is in the same directory as the server code.

const http = require('http');
const mime = require("./noype");

const hostname = '127.0.0.1';
const port = 3000;

const server = http.createServer((req, res) => {
  const cont = mime(req.url);
  res.statusCode = 200;
  res.setHeader('Content-Type', cont);
  res.end('Hello World\n');
});

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});

Workthrough

Require noype.

const mime = require("./noype");

Pass req.url to noype.

const cont = mime(req.url);

Add the result to HTTP header.

res.setHeader('Content-Type', cont);

License

BSD style - see license file.

Developer

kampamba chanda (a.k.a kampsy).
Google+: google.com/+kampambachanda
Twitter: @kampsy
email: kampambachanda@gmail.com

About

An identifier for file formats transmitted on the internet

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published