使用express作为前端和后台的中间层Demo
来源:互联网 发布:中国政治向左转知乎 编辑:程序博客网 时间:2024/06/06 01:34
搭建测试服务器
使用之前Spring boot项目的测试demo
创建nodejs创建express项目
var express = require("express");var http = require("http");var app = express();app.get('/',function(req,res){ console.log("hello express"); res.send("hello express");});app.get('/add',function(req,res){ console.log("hello express add"); var options = { host:'127.0.0.1', port:8080, path:'/add', method:'post' } var requestServer = http.request(options,function(reqSer,resSer){ console.log('STATUS: ' + reqSer.statusCode); console.log('HEADERS: ' + JSON.stringify(reqSer.headers)); reqSer.setEncoding('utf8'); reqSer.on('data', function (chunk) { console.log('BODY: ' + chunk); res.writeHead(200, {"Content-Type": "text/plain"}); res.write(chunk); res.end(); }); }); requestServer.on('error', function (e) { console.log('problem with request: ' + e.message); }); requestServer.end();});var server = app.listen(8888, function () { var host = server.address().address var port = server.address().port console.log("应用实例,访问地址为 http://%s:%s", host, port)})
运行效果
1.浏览器
2.nodejs后台
3.服务器后台
总结
服务器后台是调用python的一个测试demo,不清除的朋友只需将其当成一个controller对应的返回数据即可。
0 0
- 使用express作为前端和后台的中间层Demo
- nodejs 使用express 搭建简单前端demo
- node作为中间层的一些看法
- WebUploader 精美demo php前端和后台源代码!
- spring_02_在中间层的使用
- 前端、后台和连接前端后台的网络数据传输
- express后台接收文件以及jquery前端上传文件的方法
- emrs的住院和门诊都要搭中间层
- 客户端和中间层的解耦
- Flex Actionscript将方法作为方法的参数 使用demo
- 我可以使用XML作为后台的Web数据库吗?
- Android之使用JavaWeb项目作为后台的实现
- Android之使用JavaWeb项目作为后台的实现
- vue2+webpack+express 简单入门:从前端到后台
- react前端+node后台+mongoose+express框架搭建
- 让Java程序作为linux的Daemon后台运行 和 使用Java Service Wrapper将java程序作为linux服务并且开机自动启动
- jsp 和 html作为前端页面的区别
- 【实践】express搭建nodeJS中间层(一)
- Tomcat、JVMj的监控
- 从NPM到CNPM
- JavaWeb开发知识总结-HttpServletRequest,HttpServletResponse
- <Effective JavaScript>
- Tomcat的环境变量配置
- 使用express作为前端和后台的中间层Demo
- 素数筛选法
- MySQL数据库
- 子类转换成父类的规则
- 464. Can I Win
- 变量名命名规则,构造方法的作用,类名命名规则
- 多线程 countDownLatch
- 【android】Studio配置等相关笔记
- dom4j出现java.lang.NoClassDefFoundError: org/jaxen/JaxenException