Skip to content

ksw2000/inhpc-lab-website-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

algorithm.csie.ncku.edu.tw (Back-End)

Deploy

  1. 主機上原本有 run httpd,要先關掉
sudo service httpd stop    # 關掉 httpd
sudo service httpd start   # 重啟
  1. https 所需的驗證檔案在 /etc/letsencrypt/live/algorithm.csie.ncku.edu.tw/ 可以編輯 config/config.json

  2. config.json 檔

{
    "domain": "algorithm.csie.ncku.edu.tw", 
    "autocert": false,
    "certification": {
        "crt": "",
        "key": ""
    }
}
  • domain 配合憑證
  • autocert 設定 true 的話程式會自己從 Let's Encrypt 抓加密檔
  1. main.go 參數 -p 指定 port 預設在 8080,佈署時可以設定 443 會同時執行 http 80 和 https 443 並將 http 80 重新導向 443 https

Redirect

幫舊網站做重定向

  • /syhsieh.htm => /advisor

API

Login

  • 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"
}

Check Login

  • URL: /api/login
  • Method: Get
  • Auth required: No/Yes

Response

{
    "is": true
}

List courses file (Lecture)

  • URL: /api/file?dir=[course]
  • Method: Get
  • Auth required: Yes

This API return the files in the /files/[course]/*

List courses file (Homework or Exam)

  • 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"
        }
    ]
}

Structure

.
└── 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)

Releases

No releases published

Packages

No packages published