1 Star 0 Fork 0

bluebug2016/JavaScriptTutorial

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
server1.js 751 Bytes
一键复制 编辑 原始数据 按行查看 历史
bluebug2016 提交于 2022-03-25 17:08 +08:00 . axios
var http = require('http');
var url = require('url');
var students = [{ name: 'John', email: 'aa', age: 18 },
{ name: 'lisi', email: 'aa', age: 20 },
{ name: 'wuang', email: 'aa', age: 19 },
{ name: 'maliu', email: 'aa', age: 17 },]
http.createServer(function (request, response) {
var pathobj = url.parse(request.url, true);
switch (pathobj.pathname) {nod
case '/students':
response.writeHead(200, { 'Content-Type': 'text/json' });
response.end(JSON.stringify(students));
break;
default:
response.writeHead(200, { 'Content-Type': 'text/html' });
response.end("<h1>请访问/students</h1>".toString('utf-8'));
break;
}
}).listen(5000);
console.log('Server running at http://127.0.0.1:5000/students');
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/bluebug2016/java-script-tutorial.git
git@gitee.com:bluebug2016/java-script-tutorial.git
bluebug2016
java-script-tutorial
JavaScriptTutorial
master

搜索帮助