zoukankan      html  css  js  c++  java
  • indexzero/http-server-1-简介

    ethereumjs-vm的例子有用到这个

    看完ethereumjs-vm,再看他ethereumjs/browser-builds,然后最后看他http-server,然后就能了解ethereumjs-vm的例子ethereumjs-vm/examples/run-transactions-simple

    https://github.com/indexzero/http-server

    http-server: a command-line http server一个命令行http服务器

    http-server is a simple, zero-configuration command-line http server. It is powerful enough for production usage, but it's simple and hackable enough to be used for testing, local development, and learning.

    http-server是简单的、零配置的命令行http服务器。它足够强大,可以用于生产使用,但是它足够简单和可编程,可以用于测试、本地开发和学习

    Installing globally:全局安装

    Installation via npm:

     npm install http-server -g

    安装的版本:

    + http-server@0.11.1

    This will install http-server globally so that it may be run from the command line.

    这将全局安装http-server,以至于它能从命令行运行

    Usage:

    http-server [path] [options]

    [path] defaults to ./public if the folder exists, and ./ otherwise.

    [path]如果文件夹存在则默认为./public,否则为./

    Now you can visit http://localhost:8080 to view your server

    你可以通过访问http://localhost:8080去查看你的服务器

    Note: Caching is on by default. Add -c-1 as an option to disable caching.

    注意:默认情况下,缓存是打开的。添加-c-1作为乐意选项去取消缓存

    Available Options:有效选项

    -p or --port Port to use (defaults to 8080)  使用的端口(默认为8080)

    -a Address to use (defaults to 0.0.0.0)  使用的地址(默认为0.0.0.0

    -d Show directory listings (defaults to true)  是否显示目录列表(默认为true)

    -i Display autoIndex (defaults to true)  是否显示自动索引

    -g or --gzip When enabled (defaults to false) it will serve ./public/some-file.js.gz in place of ./public/some-file.js when a gzipped version of the file exists and the request accepts gzip encoding.  当可用时(但是默认为false,不可用),它将会在一个文件的压缩版本存在且需要接受gzip编码时,提供./public/some-file.js.gz以代替./public/some-file.js

    -e or --ext Default file extension if none supplied (defaults to html)  如果提供的是none,默认文件扩展(默认为html)

    -s or --silent Suppress log messages from output  从输出中取消日志信息

    --cors Enable CORS via the Access-Control-Allow-Origin header  通过Access-Control-Allow-Origin头可用CORS

    -o Open browser window after starting the server  在开启服务器后自动打开浏览器

    -c Set cache time (in seconds) for cache-control max-age header, e.g. -c10 for 10 seconds (defaults to 3600). To disable caching, use -c-1.  为缓存控制的最大年龄设置缓存时间(秒为单位),比如 -c10代表10秒(默认为3600)。为了取消缓存,可以使用-c-1

    -U or --utc Use UTC time format in log messages. 在日志信息中使用UTC时间格式

    -P or --proxy Proxies all requests which can't be resolved locally to the given url. e.g.: -P http://someurl.com   代理所有无法在本地解析到给定url的请求,比如:-P http://someurl.com

    -S or --ssl Enable https. 设置https可

    -C or --cert Path to ssl cert file (default: cert.pem).  ssl证书文件路径(默认为cert.pem

    -K or --key Path to ssl key file (default: key.pem).  ssl密钥文件路径(默认为key.pem

    -r or --robots Provide a /robots.txt (whose content defaults to User-agent: * Disallow: /)  提供一个/robots.txt文件(其内容默认为User-agent: * Disallow: /

    -h or --help Print this list and exit.  输出该列表内容并退出

    Magic Files

    • index.html will be served as the default file to any directory requests. index.html将作为任何目录请求的默认文件
    • 404.html will be served if a file is not found. This can be used for Single-Page App (SPA) hosting to serve the entry page. 当一个文件找不到时,404.html将被使用。这可以用于单页面应用程序(SPA)托管来服务入口页面

    Development开发

    Checkout this repository locally, then:本地查看存储库

    $ npm i
    $ node bin/http-server

    Now you can visit http://localhost:8080 to view your server

    然后你就可以访问http://localhost:8080去查看你的服务器

    You should see the turtle image in the screenshot above hosted at that URL. See the ./public folder for demo content.

    您应该可以在上面的截图中看到这个URL上托管的乌龟图像。有关演示内容,请参见./public文件夹

    运行尝试一下:

    userdeMacBook-Pro:~ user$ http-server
    Starting up http-server, serving ./public
    Available on:
      http://127.0.0.1:8080
      http://192.168.1.102:8080
    Hit CTRL-C to stop the server
    [Sat Dec 08 2018 11:01:21 GMT+0800 (中国标准时间)] "GET /favicon.ico" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:63.0) Gecko/20100101 Firefox/63.0"
    [Sat Dec 08 2018 11:01:21 GMT+0800 (中国标准时间)] "GET /favicon.ico" Error (404): "Not found"

    界面为:

  • 相关阅读:
    httpwebrequest详解【转】
    javascript中event.keycode大全
    public void Delete<T>(List<T> EntityList) where T : class, new() 这是什么意思
    Vue(基础五)_vue中用ref和给dom添加事件的特殊情况
    Vue(基础四)_总结五种父子组件之间的通信方式
    Vue(基础三)_监听器与计算属性
    vue(基础二)_组件,过滤器,具名插槽
    vue(基础一)_基本指令的使用
    JS(基础)_总结获取页面中元素和节点的方式
    node.js(node.js+mongoose小案例)_实现简单的注册登录退出
  • 原文地址:https://www.cnblogs.com/wanghui-garcia/p/10084322.html
Copyright © 2011-2022 走看看