Blog 重構

module install + sqeuwlize-cli init

1
2
3
4
5
6
7
8
9
10
11
npm install express
npm install ejs
npm install body-parser
npm install express-session
npm install connect-flash
npm install sequelize
npm install sequelize-cli
npm install mysql2
npm install bcrypt
# init
npx sequelize-cli init
閱讀全文 »

node.js create web server

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
26
27
28
29
// index.js
const http = require('http')
const server = http.createServer(handler)

function handler(req, res) {
console.log(req.url)
if (req.url === '/hello') {
res.writeHead(200, {
// 'Connect-Type': 'text/plain' - 沒有效果
'Connect-Type': 'text/html'
})
res.write('<h1>hello!</h1>')
}
else if ( req.url === '/bye'){
res.write('bye')
}
else if ( req.url === '/new'){
// 轉址
res.writeHead(301, {
'Location': '/bye'
})
}
else {
res.write('Invalid url')
}
res.end()
}

server.listen(5001)
閱讀全文 »

試 bulid

  1. NODE_ENV 不是内部或外部命令,也不是可運行的程序,或者批處理文件
    以下兩條腳本都合併兩條命令(這種操作在powershell中不被支持,在cmd中也不被支持,這是Mac中bash或Linux的shell中的獨特操作),拆分兩條腳本如下:
閱讀全文 »

常用主機

  • AWS
  • Digital Ocean
  • GCP
  • Linode
閱讀全文 »

jquery 應用於 event e.target

1
2
3
4
5
6
7
// 正確
$(document).on('change', '.checkbox', function(e) {
let element = $(e.target)
....
}
// 錯誤
let element = $('e.target')
閱讀全文 »

基本

load and check

var $ = jQuery

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="shortcut icon" href="#"/>
<title>Document</title>
<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
</head>
<body>
<script>
console.log(jQuery)
</script>
</body>
</html>
閱讀全文 »

CKEditor 4 - 所見即所得文字編輯器

  • 因 reset.css 會清掉 css default 值, 所以無法顯示出設定效果,所以要改為 normalize.css
  • htmlspecialchars HTML 跳脫字元 會忽略 tag, 所以要拿掉才會有效果(CKEditor 會保護,手動加入無效)
閱讀全文 »

header() 不加 exit() or die() 會往下執行

閱讀全文 »

mySQL

使用 SeidiSQl 連接 XAMPP,選使用者出現錯誤

1030 - Got error 176 “Read page with wrong checksum” from storage engine Aria

閱讀全文 »