-
Notifications
You must be signed in to change notification settings - Fork 0
/
myapp.py
63 lines (49 loc) · 1.49 KB
/
myapp.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
__author__ = 'halfcrazy'
#-*- coding: utf-8 -*-
from flask import Flask, request
import xml.etree.ElementTree as ET
from school import teacher_schedule, schedule, grades
from kuaidi import getposturl
app = Flask(__name__)
# app.debug=True
@app.route('/')
def index():
return "query interface for cyjw.dlut.edu.cn"
@app.route('/kuaidi', methods=['GET'])
def kuaidichaxun():
postid = request.args.get('postid')
resp = getposturl(postid)
if resp:
return resp
else:
return ''
@app.route('/grades', methods=['GET'])
def parse_grades_get():
name = request.args.get('name')
password = request.args.get('password')
password = password.replace(' ', '+')
term = request.args.get('term')
if term == None:
term = 13
flag, json_string = grades(name, password, term)
return json_string
@app.route('/schedule', methods=['GET'])
def parse_schedule_get():
name = request.args.get('name')
password = request.args.get('password')
password = password.replace(' ', '+')
flag, json_string = schedule(name, password)
return json_string
@app.route('/teacher_schedule', methods=['GET'])
def parse_teacher_schedule_get():
id = request.args.get('id')
flag, json_string = teacher_schedule(id)
return json_string
def parse_msg(rawmsgstr):
root = ET.fromstring(rawmsgstr)
msg = {}
for child in root:
msg[child.tag] = child.text
return msg
if __name__ == "__main__":
app.run(host="0.0.0.0",port=80,debug=True)