npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tiny-http

v2.0.8

Published

a simple static web server

Downloads

200

Readme

tiny-http NPM version

NPM Download

一个单文件实现的http服务器,实现类php的CGI动态调用,多进程模式可以确保子模块的异常不会引起服务中断。

安装:

local install

$npm install tiny-http

$cd tiny-http

$sudo node http.js

$sudo node http.js 8080

$sudo node http.js 8080 /webroot

//or $sudo node http.js 8080 ./webroot

global install

$sudo npm install tiny-http -g

$sudo http 8080

$sudo http 8080 ./webroot

参数说明: node http.js 端口 目录 是否自动启动浏览器(1或0)

require


   require('tiny-http').run(process.argv);

    //or

   new require('tiny-http').Server().init(8080, './webroot', {
         ip: '127.0.0.1',//可以省略
         autoOpenBrowser: true
   });

子CGI处理

详见 example

建议将example目录clone下来,然后执行

cd example
http 8080 . 1
;上面参数依次表示: 命令本身 端口号 路径 是否自动打开浏览器

特点

  • 简单高效。本服务器只实现了部分常用http传输协议(200, 403, 404, 501),所以效率相对较高 (经测试比较,静态文件处理比express快1/3左右)
  • 单文件,便于移植简合。服务器不依赖任何第三方模块,一个单文件即可实现http服务器
  • 实现了类php的CGI处理模式,模块只在被请求时才会加载。cmd模块语法编写子CGI模块,方便快捷。(见example)
  • 静态资源处理与CGI处理进程分离,CGI异常不会引起服务中断。