- 主機上原本有 run
httpd
,要先關掉
sudo service httpd stop # 關掉 httpd
sudo service httpd start # 重啟
-
https 所需的驗證檔案在
/etc/letsencrypt/live/algorithm.csie.ncku.edu.tw/
可以編輯config/config.json
檔 -
config.json 檔
{
"domain": "algorithm.csie.ncku.edu.tw",
"autocert": false,
"certification": {
"crt": "",
"key": ""
}
}
domain
配合憑證autocert
設定 true 的話程式會自己從 Let's Encrypt 抓加密檔
- main.go 參數
-p
指定 port 預設在8080
,佈署時可以設定443
會同時執行 http80
和 https443
並將 http80
重新導向443
https
幫舊網站做重定向
/syhsieh.htm
=>/advisor
- URL:
/api/login
- Method:
POST
- Auth required: No
Login success if the student_id
is in the file /login.txt
.
Request
{
"student_id": "P12345678"
}
Response
Return empty string if success
{
"err": "Authentication Fail"
}
- URL:
/api/login
- Method:
Get
- Auth required: No/Yes
Response
{
"is": true
}
- URL:
/api/file?dir=[course]
- Method:
Get
- Auth required: Yes
This API return the files in the
/files/[course]/*
- URL:
/api/file?course&dir=[course]
- Method:
Get
- Auth required: Yes
This API return the files in the
/files/[course]/course/
Response
{
"files": [
{
"name": "f1.pdf",
"url": "/files/[course]/f1.pdf"
},
{
"name": "f2.ppt",
"url": "/files/[course]/f2.ppt"
}
]
}
.
└── algorithm.csie.ncku.edu.tw/
├── angular/
│ ├── index.html
│ ├── (generated by angular)
│ └── ...
├── config/
│ ├── config.json
│ └── config.go
├── files/
│ ├── 2023-algorithm/
│ │ ├── 07_Quicksort.ppt
│ │ └── ...
│ ├── 2024-algorithm
│ └── ...
├── main.go
├── go.mod
├── go.sum
├── login.txt (student ID list)
├── run.sh (run server)
└── stop.sh (stop server)