首页
学习
活动
专区
圈层
工具
发布
综合排序最热优先最新优先
时间不限
http-server 的安装和使用
http-server 是什么?有什么用? http-server 是一个轻量级的 http 服务器,它可以让任意一个目录成为服务器的目录,讲的有点模糊? 这个工具可以让你直接在当前目录开个本地服务[此处应该有掌声] 使用方法 1.安装 全局安装 npm install -g http-server 按需安装 使用 npx 可以直接运行,而无需先安装 。 不了解 npx 的童鞋可以看看我写的这篇文章:npm 和 npx 的区别 npx http-server [path] [options] 2.运行 打开命令行工具,切换到要开服务的目录下,执行 http-server 还可以设置一些参数 -p或--port 使用的端口(默认为 8080) -a 要使用的地址(默认为 0.0.0.0) 快点耍起来吧~ github:https://github.com/http-party/http-server 首发自:http-server 的安装和使用 - 小鑫の随笔
小鑫
2022-04-26
7.6K0
标签:
使用http-server搭建web服务器
npm install http-server -g 创建项目文件夹 ,在根目录下 执行命令 http-server 启动一个允许跨域的服务器 http-server --cors=Access-control-Allow-Origin
lilugirl
2019-05-28
1.5K0
标签:
http-server 超轻量级web服务器
Http-server是基于nodejs的http服务器,它最大好处就是: 可以使任意一个目录成为服务器的目录,完全抛开后台的沉重工程,直接运行想要的js代码。    1 安装nodejs   为了运行http-server,首先要安装nodejs。    可以参考前一篇帖子,安装Nodejs   2 使用npm安装http-server   这里注意要使用-g选项,安装成全局的,这样我们才可以在任意的目录使用。    输入下面的命令:   npm install http-server -g   3 在任意目录运行:   http-server就可以以该目录为跟启动一个服务器 ?   
用户1154259
2018-01-17
2.7K0
标签:
http-server快速启动localhost与iPhone X兼容
之前分享过用webpack快速搭建启动一个localhost访问静态资源,其实node还提供了一个更简单的插件http-serverhttp-server是一个简单的零配置的命令行http服务器,非常简单而且非常强大。 安装:npm install http-server -g 使用:在某个目录下启动:http-server 比如我在我的G盘启动 ? 那我我就可以直接访问G盘目录下的所有文档: ? -p修改端口访问:http-server -p 8085 -o自动打开服务器http-server -o 其他的可以自己试一下,我改使用地址和启动HTTPS都有问题,估计跟服务原理有点关系。 参考地址:https://www.npmjs.com/package/http-server iPhone X刚出来的时候,还是造成了一些小轰动,对于前端来说,也就是底部这一块比较头疼。
wade
2020-04-24
9060
标签:
介绍一款便捷的http服务工具http-server
在写前端页面时,经常会在浏览器运行html页面,此工具可以快速在本地启动一个http服务器 http-server可以用来干啥? 做模拟数据 做静态资源服务器 做调试、测试的前端服务器 做代理转发 *本地需要先安装node环境 1.安装http-server npm install http-server -g 2.启动参数: - robots.txt (whose content defaults to ‘User-agent: *\nDisallow: /’) -h or --help 打印以上列表并退出 3.使用 进入项目根目录 http-server
薛定喵君
2019-11-08
3.5K0
标签:
用Go语言建立http-server响应对JSON数据对象进行编码与解码
摘要 本文将演示如何使用Go语言中encoding/json package,结合建立一台http-server响应对JSON数据对象进行编码与解码的操作。 "lastname":"Mars","age":48}' http://localhost/decode curl -s http://localhost/encode 完结 以上就是用Go语言建立http-server
Balliol Chen
2022-05-12
2.3K0
标签:
简单的零配置命令行 http 服务器--http-server入门
简介 http-server是一个简单的零配置命令行http服务器。 而基于http协议的http-server就是一个不错的选择 2、处理页面跨域 当页面含有跨域的请求,此时可以利用http-server,使用命令 http-server -p 8080 -P https 示例 进入目标文件夹,输入hs或者http-server命令,不过推荐使用如下命令 http-server -c-1 只输入http-server的话,更新了代码后,页面不会同步更新。 总结 http-server可以做静态资源服务器,也可以做调试、测试的前端服务器。甚至可以用于实现前后端分离。 还没有使用过的朋友,可以尝鲜下 官方文档 https://github.com/http-party/http-server
lyb-geek
2022-03-04
1.2K0
标签:
简单的零配置命令行 http 服务器--http-server入门
简介 http-server是一个简单的零配置命令行http服务器。 而基于http协议的http-server就是一个不错的选择 2、处理页面跨域 当页面含有跨域的请求,此时可以利用http-server,使用命令 http-server -p 8080 -P https 示例 进入目标文件夹,输入hs或者http-server命令,不过推荐使用如下命令 http-server -c-1 只输入http-server的话,更新了代码后,页面不会同步更新。 [示例.png] [示例.png] [示例.png] 总结 http-server可以做静态资源服务器,也可以做调试、测试的前端服务器。甚至可以用于实现前后端分离。 还没有使用过的朋友,可以尝鲜下 官方文档 https://github.com/http-party/http-server
lyb-geek
2020-07-08
8.4K0
标签:
如何启动一个本地静态服务器
http-server http-server[1]是基于node.js的HTTP 服务器,它最大的好处就是:可以使用任意一个目录成为服务器的目录,完全抛开后端的沉重工程,直接运行想要的js代码 安装 npm install -g http-server 启动 http-server就可以以 该目录为根目录启动一个服务器 http-server [path] [options] path是目录的路径名称 [2] 使用 cd test/ http-server -p 8900 你可以把 http-server -p 8900 写入到 package.json 文件中的 scripts 字段中 "scripts ": { "dev": "http-server -p 8900" }, 参考资料 [1]http-server: https://github.com/indexzero/http-server [2]http-server: https://github.com/indexzero/http-server#available-options
木子星兮
2020-07-16
3.6K0
标签:
Windows下通过命令行搭建HTTP/HTTPS服务器
在我们进行开发时,有时候遇到通过HTTP协议对服务器的数据进行访问的需求,因此我们需要搭建一个HTTP服务器,上文已讲解了通过界面配置HTTP服务器,本文使用命令行的方式在windows下通过Node.js的http-server 服务命令去搭建一个本地服务 一、搭建前的确认工作 win+R弹出运行后输入cmd进入到windows的命令行窗口,执行http-server -v,若执行结果如下图,则说明你之前已安装了服务,可以直接http-server 开启部署服务,可以直接阅读四 若执行http-server -v结果为**‘http-server -v’ 不是内部或外部命令,也不是可运行的程序 或批处理文件**,则先确认是否安装了Node.js 服务 1、下载http-server服务 命令行下输入npm install http-server -g命令进行全局安装http-server服务 2、确认安装成功 命令行下输入命令http-server -v可查看该服务是否安装成功 四、开启部署服务 1、开启部署服务 命令行下输入http-server命令,输入命令后,窗口中会有2个浏览地址,复制其中一个地址在浏览器中即可访问 2、浏览器访问验证
Gnep@97
2023-08-10
9K0
标签:
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档