一、概述
场景:1.新建一个简单的https服务,并监听8080端口。2.将该端口下的public目录发布为静态资源目录,如:文本、图片、网页、视频等。
3.访问地址:https://localhost:8080/
二、相关代码
‘use strict‘//使用严格的javascript语法 const https = require(‘https‘); const express = require(‘express‘); const serve_index = require(‘serve-index‘); const fs = require(‘fs‘); const options={ key: fs.readFileSync(‘D:/wei.yang/tony/code/webrtc/openssl/key.pem‘), cert: fs.readFileSync(‘D:/wei.yang/tony/code/webrtc/openssl/key-cert.pem‘) }; const app = express(); app.use(serve_index(‘./public‘)); app.use(express.static(‘./public‘)); const https_server = https.createServer(options,app); https_server.listen(8080);
三、相关截图