forked from imagemlt/SEUcurricular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebserver.py
43 lines (36 loc) · 1.07 KB
/
webserver.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
#!/usr/bin/env python
#coding=utf-8
import web
import curricular
from bs4 import BeautifulSoup
urls=(
"/","index",
"/table","table"
)
app=web.application(urls,globals())
class index:
def GET(self):
render=web.template.render("templates")
bs1=curricular.getopener()[2]
choicelist=[]
for i in bs1.findAll('option'):
choicelist.append(i.string)
print choicelist
if web.input().get("set") is not None:
return render.index(choicelist,True)
else:
return render.index(choicelist,False)
class table:
def POST(self):
render=web.template.render("templates")
No=web.input().get("No")
year=web.input().get("year")
bs1=curricular.getTable(a=No,y=year)
if bs1 is None:
raise web.seeother("/?set=1")
tab=curricular.getTimetable(bs1)
stuinfo=curricular.getStuinfo(bs1)
classes,total=curricular.getClasses(bs1)
return render.table(tab,stuinfo,total,classes)
if __name__=="__main__":
app.run()