NODE.JS的简单的例子
2016-07-18 12:07
417 查看
今天试了一下node.js 创建一个服务居然如此的简单,没忍住要分享给大家!
brew cask install node
You can use Connect and ServeStatic with Node.js for this:
1.Install connect and serve-static with NPM
$ npm install connect serve-static
2.Create server.js file with this content:
var connect = require('connect');
var serveStatic = require('serve-static');
connect().use(serveStatic("/Users/jiangtao/site/ ")).listen(8080);
3.Run with Node.js
$ node server.js
You can now go to http://localhost:8080/yourfile.html
把文件放在/Users/jiangtao/site/ 目录就好
示例文件下载:ex.js
server.js
参考:http://nodejs.org/
LikeBe
the first to like this
No labels
Edit
Labels
1.安装NODE.JS
brew cask install node
2.写一个简单的例子,保存为ex.js
3.运行
4.看,hello dongdong
增强版(访问目录下的所有文件)
You can use Connect and ServeStatic with Node.js for this:
1.Install connect and serve-static with NPM
$ npm install connect serve-static
2.Create server.js file with this content:
var connect = require('connect');
var serveStatic = require('serve-static');
connect().use(serveStatic("/Users/jiangtao/site/ ")).listen(8080);
3.Run with Node.js
$ node server.js
You can now go to http://localhost:8080/yourfile.html
把文件放在/Users/jiangtao/site/ 目录就好
示例文件下载:ex.js
server.js
参考:http://nodejs.org/
LikeBe
the first to like this
No labels
Edit
Labels
相关文章推荐
- Namenode HA原理详解(脑裂)
- EventEmitter 使用
- nodejs 阻塞与非阻塞
- 19. Remove Nth Node From End of List
- nodejs & npm
- react,react native,webpack,ES6,node.js----------今天上午学了一下node.js
- Webstorm+node.js
- 使用nssm在windows服务器上部署nodejs的express项目
- node-sass 安装失败的解决措施
- hadoop之——datanode节点超时时间设置
- NodeJs——(15)动态视图助手
- hadoop中datanode无法启动
- 如何在window本地按章nodejs
- Hadoop NameNode元数据相关文件目录解析
- nodejs的调试
- nodejs 的一些PHP函数库
- gitbook安装与使用
- 【译】深入理解python3.4中Asyncio库与Node.js的异步IO机制
- 24. Swap Nodes in Pairs
- 19. Remove Nth Node From End of List