提交 1bfc46d5 编写于 作者: C CodFrm

https的问题

上级 b9a42045
...@@ -4,3 +4,5 @@ package-lock.json ...@@ -4,3 +4,5 @@ package-lock.json
coverage coverage
typings typings
typings.json typings.json
certificate
...@@ -13,6 +13,21 @@ ...@@ -13,6 +13,21 @@
npm install npm install
npm run build npm run build
``` ```
## Server
搭配了一个服务器程序,这个服务器将会记录你正确的答题答案,并不会记录你的任何账号信息
并且接口没有任何权限,全由插件提交上传,还请大家不要故意上传错误的答案 (๑• . •๑)
因为超新慕课是https的原因,所以服务器配置需要https
环境:
* Node.js
* Mongodb
```
npm install
npm run server
```
## 安装 ## 安装
Chrome: Chrome:
......
module.exports = { module.exports = {
url: "http://blog.icodef.com:8080/", url: "https://blog.icodef.com:8081/",
version: 1.3, version: 1.3,
update: 'http://blog.icodef.com/2018/01/25/1304', update: 'http://blog.icodef.com/2018/01/25/1304',
enforce: false enforce: false
......
...@@ -10,7 +10,6 @@ window.onload = function () { ...@@ -10,7 +10,6 @@ window.onload = function () {
return; return;
} }
} }
this.console.log(localStorage.getItem("fresh"));
injected(document, 'mooc.js'); injected(document, 'mooc.js');
document.head.setAttribute('chrome-url', chrome.extension.getURL('')); document.head.setAttribute('chrome-url', chrome.extension.getURL(''));
}) })
......
...@@ -116,7 +116,6 @@ module.exports = function (_this, elLogo, index, over) { ...@@ -116,7 +116,6 @@ module.exports = function (_this, elLogo, index, over) {
retJson.push(tmpJson); retJson.push(tmpJson);
} }
//提交数据 //提交数据
console.log(JSON.stringify(retJson));
common.post(moocServer.url + 'answer', JSON.stringify(retJson)); common.post(moocServer.url + 'answer', JSON.stringify(retJson));
} }
/** /**
......
...@@ -4,9 +4,35 @@ const app = express(); ...@@ -4,9 +4,35 @@ const app = express();
const moocModel = require('./mooc'); const moocModel = require('./mooc');
const md5 = require("md5"); const md5 = require("md5");
const config = require('../config'); const config = require('../config');
var mooc = new moocModel(); var path = require('path');
var fs = require('fs');
const http = require('http');
const https = require('https');
var privateKey = fs.readFileSync(path.join(__dirname, './certificate/private.key'), 'utf8');
var certificate = fs.readFileSync(path.join(__dirname, './certificate/file.crt'), 'utf8');
var credentials = {
key: privateKey,
cert: certificate
};
var httpServer = http.createServer(app);
var httpsServer = https.createServer(credentials, app);
var PORT = 8080;
var SSLPORT = 8081;
//创建http服务器
httpServer.listen(PORT, function () {
console.log('HTTP Server is running on: http://localhost:%s', PORT);
});
//创建https服务器
httpsServer.listen(SSLPORT, function () {
console.log('HTTPS Server is running on: https://localhost:%s', SSLPORT);
});
var mooc = new moocModel();
app.use(bodyParser.json()); app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ app.use(bodyParser.urlencoded({
extended: true extended: true
...@@ -105,10 +131,4 @@ app.get('/answer', function (req, res) { ...@@ -105,10 +131,4 @@ app.get('/answer', function (req, res) {
} }
}); });
} }
})
var server = app.listen(8080, function () {
var host = server.address().address
var port = server.address().port
console.log("Server started successfully\nHome URL:http://%s:%s", host, port)
}) })
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册