FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
node-tutorial/server/httpsServer/express/server.js at master · Wscats/node-tutorial · GitHub
Wscats
/
node-tutorial
Public
Notifications
You must be signed in to change notification settings
Fork
94
Star
558
Code
Issues
55
Pull requests
2
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
node-tutorial
/
server
/
httpsServer
/
express
/
server.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
25 lines (25 loc) · 843 Bytes
Breadcrumbs
node-tutorial
/
server
/
httpsServer
/
express
/
server.js
Copy path
File metadata and controls
25 lines (25 loc) · 843 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const
express
=
require
(
'express'
)
const
path
=
require
(
'path'
)
const
fs
=
require
(
'fs'
)
const
https
=
require
(
'https'
)
// 根据项目的路径导入生成的证书文件
const
privateKey
=
fs
.
readFileSync
(
path
.
join
(
__dirname
,
'../github.key'
)
,
'utf8'
)
const
certificate
=
fs
.
readFileSync
(
path
.
join
(
__dirname
,
'../github.crt'
)
,
'utf8'
)
const
credentials
=
{
key
:
privateKey
,
cert
:
certificate
,
}
// 创建express实例
const
app
=
express
(
)
// 处理请求
app
.
get
(
'/'
,
async
(
req
,
res
)
=>
{
res
.
status
(
200
)
.
send
(
'Hello World!'
)
}
)
// 创建https服务器实例
const
httpsServer
=
https
.
createServer
(
credentials
,
app
)
// 设置https的访问端口号
const
SSLPORT
=
8889
// 启动服务器,监听对应的端口
httpsServer
.
listen
(
SSLPORT
,
(
)
=>
{
console
.
log
(
`HTTPS Server is running on: https://localhost:
${
SSLPORT
}
`
)
}
)
Back
|
FazBrowse Home
|
New Git URL