代码拉取完成,页面将自动刷新
// const https = require('https');
const https = require('http');
const fs = require('fs');
const express = require('express')
const cookieParser = require('cookie-parser');
const bodyParser = require('body-parser');
const app = express();
const queryString = require('querystring');
const URL = require('url');
const socket = require('./service/socket');
const router = require('./routes/router').router;
//获取认证证书
// var key = fs.readFileSync('./key/2_www.liudongtushuguan.cn.key');
// var cert = fs.readFileSync('./key/1_www.liudongtushuguan.cn_bundle.crt');
// var options = {
// key : key,
// cert : cert,
// };
//配置小程序二维码生成文件
app.use('/index', express.static('index'));
app.use(cookieParser());
app.use(bodyParser.json());
// const httpsServer = https.createServer(options,app);
const httpsServer = https.createServer(app);
httpsServer.listen(8080,() =>{
console.log('listening 443 port');
});
socket(httpsServer);
app.use(router);
// app.get('/', (req , res) =>{
// console.log('someone requested!');
// res.cookie('mycookie','value',{time : new Date()});
// res.status(200).send('Welcome to liudongtushuguan!');
// });
// app.get('/cookie',(req , res) => {
// console.log(req.cookies);
// //var mycookie = req.cookies.mycookie;
// res.end('mycookie');
// });
// const wss = new WebSocket.Server({server : httpsServer});
// wss.on('connection',(ws, req) => {
// let sessionId = queryString.parse(URL.parse(req.url).query).sessionId;
// ws.id = sessionId;
// console.log('someone connect');
// console.log(wss.clients);
// wss.clients.forEach((client) => {
// console.log(Object.keys(client));
// });
// ws.on('message' , (msg) => {
// let msgObj = JSON.parse(msg);
// if(sessions[msgObj.targetId]){
// wss.clients.forEach((client) => {
// if(client.id === msgObj.targetId){
// let data = {
// time : msgObj.time,
// borrower :msgObj.nickName,
// book :msgObj.bookName,
// borrowerId : sessions[sessionId],
// bookId : msgObj.bookId,
// wxNum : msgObj.wxNum,
// phoneNum : msgObj.phoneNum,
// msg : msgObj.msg
// };
// client.send(JSON.stringify(data));
// }
// });
// }
// console.log(msg);
// //ws.send('you send '+msg);
// });
// //ws.send('hello');
// });
// app.get('/login',(req,res) => {
// res.status(200);
// console.log(req.query);
// res.json({"code" : req.query});
// });
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。