zoukankan      html  css  js  c++  java
  • 安利一个简单的零配置的命令行http服务器(http-server)

    http-server是一个简单的、零配置的命令行http服务器。它在生产环境是非常有用的,但是它只能简单的在本地环境进行开发、使用和学习。

    全局安装:

     npm install http-server -g 

    使用npm命令安装,如果没有npm环境,请先现在配置npm命令。
    NPM
    下载:https://www.npmjs.com/

    本次操作会通过命令行把http-server全局安装。

    http-server使用方法:

     http-server [path] [options] 

    【path】参数,默认路径是./public如果这个文件存在,否则就是当前目录!

    好了,现在你可以打开 http://localhost.8080,观看你的网站了。

    http-server默认是在当前路径下开始http服务器。

    有效的配置项目:
    -p 指定端口号,默认8080
    -a 地址使用(默认为0.0.0.0)
    -d 显示目录列表(默认为“True”)
    -i 显示自动索引 (defaults to 'True')
    -e or --ext 如果没有提供默认的扩展名(defaults to 'html')
    -s or --silent 打印输出日志
    --cors Enable CORS via the Access-Control-Allow-Origin header
    -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.
    -U or --utc Use UTC time format in log messages.
    -P or --proxy Proxies all requests which can't be resolved locally to the given url. e.g.: -P http://someurl.com
    -S or --ssl Enable https.
    -C or --cert Path to ssl cert file (default: cert.pem).
    -K or --key Path to ssl key file (default: key.pem).
    -r or --robots Provide a /robots.txt (whose content defaults to 'User-agent: * Disallow: /')
    -h or --help Print this list and exit.

    附录:npm管理包地址。

    https://www.npmjs.com/package/http-server

    本文欢迎转载,转载请注明出处,如果涉及侵权,请企鹅:723887809。
  • 相关阅读:
    P4396 [AHOI2013]作业
    NOIP2018普及T2暨洛谷P5016 龙虎斗
    NOIP2018普及T1暨洛谷P5015 标题统计 题解
    【交题大桥】团队信息存档
    markdown浅谈
    洛谷P1690 贪婪的Copy 题解
    洛谷P4994 终于结束的起点 题解
    洛谷P4995 跳跳!题解
    这么多都变了,洛谷4还会远吗?
    洛谷P1396 营救 题解
  • 原文地址:https://www.cnblogs.com/toxufe/p/5786578.html
Copyright © 2011-2022 走看看