-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserver.py
69 lines (58 loc) · 1.87 KB
/
server.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from fastapi import FastAPI, HTTPException
import uvicorn
from model.req_models import *
import scheduling
app = FastAPI (
title="Daitssu Crawl Server",
description="다잇슈 크롤링 서버 api 문서입니다.",
version="1.0.0"
)
scheduling.start_scheduling()
@app.post("/smart-campus/crawling")
async def smart_campus_controller(smart_campus_req: SmartCampusReq):
"""
student_id는 학번을 의미합니다.
"""
from smart_campus.smart_campus import smart_campus_crawling
try:
result = smart_campus_crawling(smart_campus_req.token, smart_campus_req.student_id)
except:
raise HTTPException(status_code=400, detail="에러가 발생 했습니다.")
return result
@app.post("/smart-campus/auth")
async def auth_controller(user_info: UserInfo):
"""
student_id는 학번을 의미합니다.
"""
from smart_campus.auth_token import get_auth_token
try:
result = get_auth_token(user_info)
except:
raise HTTPException(status_code=400, detail="로그인 정보를 다시 확인해주세요.")
return result
@app.get("/fun-system")
async def fun_system_controller():
"""
현재 정상 이용 가능합니다.
"""
from fun_system.fun_system import fun_system_crawling
result = fun_system_crawling(10)
return result
@app.get("/notice/ssu-catch")
async def ssu_catch_controller():
"""
현재 정상 이용 가능합니다.
"""
from notice.ssu_catch import ssu_catch_crawling
result = ssu_catch_crawling()
return result
@app.get("/notice/computer")
async def computer_department_controller():
"""
현재 정상 이용 가능합니다.
"""
from notice.computer import computer_department_crawling
result = computer_department_crawling()
return result
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=5000)