Skip to content

Commit

Permalink
Merge pull request #13 from l7wei/main
Browse files Browse the repository at this point in the history
feat: 增加圖書館失物招領, 電子報等功能
  • Loading branch information
l7wei authored Nov 6, 2023
2 parents 9475f5c + e13dd9e commit 40a0d7c
Show file tree
Hide file tree
Showing 16 changed files with 556 additions and 289 deletions.
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# certificates
*.pem

# temp files
temp/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down Expand Up @@ -150,5 +156,3 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

/temp
158 changes: 158 additions & 0 deletions data/newsletter_list.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
[
{
"name": "藝術文化總中心電子報",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-85-"
},
{
"name": "域報 Field Cast",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-84-"
},
{
"name": "校長同意權人投票事務委員會",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-80-"
},
{
"name": "國立清華大學校長遴選委員會",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-71-"
},
{
"name": "清華校友總會會務訊息",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-69-"
},
{
"name": "築思脈動(Pulse of Education)",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-68-"
},
{
"name": "心諮系雙週例講座",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-67-"
},
{
"name": "愛慾電子報報",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-61-"
},
{
"name": "教學發展中心電子報-教師",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-56-"
},
{
"name": "清華校友電子報",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-8-"
},
{
"name": "清華大學化學系電子報",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-48-"
},
{
"name": "國立清華大學核工暨工科系友會電子報",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-46-"
},
{
"name": "國立清華大學動機系系友電子報",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-47-"
},
{
"name": "清華大學化工系友電子報",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-45-"
},
{
"name": "國立清華大學學生會電子報",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-44-"
},
{
"name": "台灣語言學通訊",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-43-"
},
{
"name": "教務處綜合教務組電子報",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-52-"
},
{
"name": "課務電子報",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-40-"
},
{
"name": "清華大學工工系電子報",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-39-"
},
{
"name": "語文中心電子報",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-38-"
},
{
"name": "eecs-students",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-36-eecs-students"
},
{
"name": "科管院職涯電子報",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-35-"
},
{
"name": "人事室電子報",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-34-"
},
{
"name": "研發處電子報-教職",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-33-"
},
{
"name": "學生事務報-學生",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-28-"
},
{
"name": "數學系電子報",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-27-"
},
{
"name": "電機工程學系電子報(學生)",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-25-"
},
{
"name": "秘書處-全校教職員",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-57-"
},
{
"name": "住宿書院電子報",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-20-"
},
{
"name": "主計室電子報",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-19-"
},
{
"name": "國立清華大學圖書館-學生",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-18-"
},
{
"name": "諮商中心-心窩報報",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-16-"
},
{
"name": "NTHU-Newsletter",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-15-nthu-newsletter"
},
{
"name": "NTHU-Division of Health Service",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-14-nthu-division-of-health-service"
},
{
"name": "人社院學士班電子報",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-11-"
},
{
"name": "人文社會學院電子報",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-53-"
},
{
"name": "新聞剪輯電子報",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-10-"
},
{
"name": "清華簡訊",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-9-"
},
{
"name": "計中-教育訓練",
"link": "https://newsletter.cc.nthu.edu.tw/nthu-list/index.php/zh/home-zh-tw/listid-7-"
}
]
2 changes: 1 addition & 1 deletion kubernetes/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ spec:
- name: LOGURU_LEVEL
value: ERROR
- name: PORT
value: "5000"
value: 5000
---
apiVersion: v1
kind: Service
Expand Down
16 changes: 9 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
import os
import uvicorn
from dotenv import load_dotenv
from scripts.ssl.generate_ssl import generate_certificate

load_dotenv()

if __name__ == "__main__":
ssl_path = "src/utils/openssl/"
ssl_path = "scripts/ssl/"
generate_certificate(path=ssl_path)
ssl_keyfile = ssl_path + "key.pem"
ssl_certfile = ssl_path + "cert.pem"
if os.getenv("ENV") == "development":
# Development
# Run the server
uvicorn.run(
"src:app",
app="src:app",
host="0.0.0.0",
port=int(os.getenv("PORT") or 5000),
log_level="debug",
reload=True, # reload the server every time code changes
ssl_keyfile="src/utils/openssl/key.pem",
ssl_certfile="src/utils/openssl/cert.pem",
)
else:
# Production
# Run the server
uvicorn.run(
"src:app",
app="src:app",
host="0.0.0.0",
port=int(os.getenv("PORT") or 5000),
log_level="error",
workers=2,
ssl_keyfile="src/utils/openssl/key.pem",
ssl_certfile="src/utils/openssl/cert.pem",
ssl_keyfile=ssl_keyfile,
ssl_certfile=ssl_certfile,
)
6 changes: 3 additions & 3 deletions src/utils/openssl/openssl.py → scripts/ssl/generate_ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@


def generate_certificate(
organization="huixing.tw",
common_name="api.huixing.tw",
organization="國立清華大學學生會",
common_name="api.nthusa.tw",
country="TW",
duration=(10 * 365 * 24 * 60 * 60),
path="src/utils/openssl/",
path="",
keyfilename="key.pem",
certfilename="cert.pem",
):
Expand Down
2 changes: 2 additions & 0 deletions src/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
energy,
librarys,
locations,
newsletters,
phones,
resources,
rpage,
Expand All @@ -18,6 +19,7 @@
app.include_router(librarys.router, prefix="/lib", tags=["Library"])
app.include_router(librarys.router, prefix="/librarys", tags=["Library"])
app.include_router(locations.router, prefix="/locations", tags=["Locations"])
app.include_router(newsletters.router, prefix="/newsletters", tags=["Newsletters"])
app.include_router(phones.router, prefix="/phones", tags=["Phones"])
app.include_router(resources.router, prefix="/resources", tags=[])
app.include_router(rpage.router, prefix="/rpage", tags=["Rpage"])
83 changes: 0 additions & 83 deletions src/api/models/librarys.py

This file was deleted.

Loading

0 comments on commit 40a0d7c

Please sign in to comment.