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。
  • 相关阅读:
    将centos_yum源更换为阿里云(官方文档)
    JIRA 破解文件研究(Win 7环境)
    告别拖延症,你也可以轻松做到
    VS2015 + EF6连接MYSQL
    start-stop-daemon
    stm32开发板无法正常写入的问题或者写入后无法正常运行的问题
    进制转换
    回文判断程序
    C语言结构体指针的引用问题
    升级/安装主题插件提示权限不足 输入FTP解决办法
  • 原文地址:https://www.cnblogs.com/toxufe/p/5786578.html
Copyright © 2011-2022 走看看