1 Star 0 Fork 43

霈晨/mockcat

forked from KingWTD/mockcat 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
server.js 898 Bytes
一键复制 编辑 原始数据 按行查看 历史
KingWTD 提交于 2018-10-10 17:25 . Set IPv4 address
/**
* Mockcat Server
* @author Wangtd
*/
const http = require('http');
const url = require('url');
const fs = require('fs');
const path = require('path');
const express = require('express');
const bodyParser = require('body-parser');
const config = require('./config.js');
const mocker = require('./lib/mocker.js');
const router = require('./lib/router.js');
var app = express();
app.use('/app', express.static(path.join(__dirname, 'app')));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json({ type: 'application/json', limit: '5mb' }));
app.use('/mock', router);
app.use('/', mocker.listen(config.mockDir));
//set port & ipv4 address
http.createServer(app).listen(config.port, '0.0.0.0', function(error) {
if (error) {
console.error(error);
} else {
console.log('Mockcat server is running at http://localhost:%d/', config.port);
}
});
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
NodeJS
1
https://gitee.com/chengxipei/mockcat.git
[email protected]:chengxipei/mockcat.git
chengxipei
mockcat
mockcat
master

搜索帮助