Total Pageviews

Thursday, 10 May 2018

三款file server(directory server)程序

Your personal HTTP file server in Go.

A basic HTTP file server in Go
GoDoc

Features

  • Fast
  • Single binary
  • Logs with modifiable timestamps and response times (colorized when running in a terminal)
  • Directory listing supporting multiple content types (html,json and xml) via the Accept header
  • Directory downloads via on-demand zip and tar archives
  • Optional PushState (HTML5 History API) mode (missing directories returns the root)
  • LiveReload for automatic browser refresh (combines with this Chrome extension)
  • Fallback proxy (missing requests defer to another server)

Install

Binaries
See the latest release or download it with this one-liner: curl i.jpillora.com/serve | bash
Source
$ go get -v github.com/jpillora/serve

Usage

serve --help
<tmpl,code: go run main.go --help>

  Usage: serve [options] [directory]
  
  [directory] from which files will be served (default .)
  
  Options:
  --host, -h        Host interface (default 0.0.0.0)
  --port, -p        Listening port (default 3000)
  --livereload, -l  Enable LiveReload, a websocket server which triggers 
                    browser refresh after each file change
  --pushstate, -s   Enable PushState mode, causes missing directory paths 
                    to return the root index.html file, instead of a 404. 
                    This allows correct use of the HTML5 History API.
  --noindex, -n     Disable automatic loading of index.html
  --noslash         Disable automatic slash insertion when loading an 
                    index.html or directory
  --nolist          Disable directory listing
  --noarchive       Disable directory archiving (download directories by 
                    appending .zip .tar .tar.gz, archives are streamed 
                    without buffering)
  --quiet, -q       Disable all output
  --timefmt, -t     Set timestamp output format (default [2006-01-02 
                    15:04:05.000])
  --open, -o        On server startup, open the root in the default browser 
                    (uses the 'open' command)
  --fallback, -f    Requests that yeild a 404, will instead proxy through 
                    to the provided path (swaps in the appropriate Host 
                    header)
  --help          
  --version, -v   
  
  Version:
    0.0.0
  
  Read more:
    https://github.com/jpillora/serve
  

from https://github.com/jpillora/serve
--------------------------
 
Simple command-line file / directory server.
 

serve

Simple 5 minute command-line file / directory server built with connect, inspired by nodejitsu's http-server to show off the simplicity and flexibility of connect as a modular server.

Installation

$ npm install -g tj/serve Note: the "serve" name on NPM (as of 2.x) refers to https://github.com/zeit/serve.

Usage

Usage: serve [options] [dir] Options: -h, --help output usage information -V, --version output the version number -o, --open opens a browser window to this server -a, --auth <user>:<pass> specify basic auth credentials -F, --format <fmt> specify the log format string -p, --port <port> specify the port [3000] -r, --root <root> specify the root directory [] --https-port <port> specify the port [3443] -H, --hidden enable hidden file serving -S, --no-stylus disable stylus rendering -J, --no-jade disable jade rendering --no-less disable less css rendering -I, --no-icons disable icons -L, --no-logs disable request logging -D, --no-dirs disable directory serving -f, --favicon <path> serve the given favicon -C, --cors allows cross origin access serving -s, --https also serve over https --key key file path for https --cert certificate file for https --ca CA certificate file for https --compress gzip or deflate the response --exec <cmd> execute command on each request

Examples

HTTP Accept support built into connect.directory():
$ curl http://local:3000/ -H "Accept: text/plain" bin History.md node_modules package.json Readme.md Requesting a file:
$ curl http://local:3000/Readme.md # serve ... 

from https://github.com/tj/serve
--------

Static file serving and directory listing

serve

Build Status Join the community on Spectrum
Have you ever wanted to share a project on your network by running just a command? Then this module is exactly what you're looking for: It provides a neat interface for listing the directory's contents and switching into sub folders.
In addition, it's also awesome when it comes to serving static sites!
screenshot

Usage

Firstly, install the package from npm (you'll need at least Node.js 7.6.0):
npm install -g serve
Alternatively, you can use Yarn to install it:
yarn global add serve
Once that's done, you can run this command inside your project's directory:
serve [options] <path>

Options

Run this command to see a list of all available options:
serve help

Authentication

If you set the --auth flag, the package will look for a username and password in the SERVE_USER and SERVE_PASSWORD environment variables.
As an example, this is how such a command could look like:
SERVE_USER=leo SERVE_PASSWORD=1234 serve --auth

API

You can also use the package inside your application. Just load it:
const serve = require('serve')
And call it with flags (run this command for the full list):
const server = serve(__dirname, {
  port: 1337,
  ignore: ['node_modules']
})
Later in the code, you can stop the server using this method:
server.stop()

Contributing

  1. Fork this repository to your own GitHub account and then clone it to your local device
  2. Uninstall serve if it's already installed: npm uninstall -g serve
  3. Link it to the global module directory: npm link
After that, you can use the serve command everywhere. Here's a list of issues that are great for beginners.

from https://github.com/zeit/serve ,https://github.com/vercel/serve
---------------------------------------------
 
相关帖子:https://briteming.blogspot.com/2017/04/blog-post_5.html
-----------------------------------------------
 
  • 一个简易的,单文件部署的本地Http服务器
  • 基于Golang 1.16的embed功能
  • 方便普通使用者运行和部署

使用方法

从Release下载

手动构建

  • 安装golang 1.16以上的版本(Tips 2020/12/28: Golang1.16当前为beta状态)
go generate
go build
from https://github.com/unlock-music/simple-server 
 


No comments:

Post a Comment