-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
108 lines (80 loc) · 3.23 KB
/
app.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
from chalice import Chalice, Response
from chalicelib.ews import ews
from chalicelib.ics import ics
from chalicelib.dining import dining
from chalicelib.library import library
from chalicelib.athletic import athletic
from chalicelib.daily import daily
from chalicelib.building import buildings
from chalicelib.laundry import laundry
app = Chalice(app_name='UIUC-API')
@app.route('/')
def index():
return Response(body='Welcome to University of Illinois, Urbana-Champaign API',
status_code=200,
headers={'Content-Type': 'text/plain'})
# EWS router
@app.route('/ews', methods=['GET'])
def get_ews_status():
return ews.EWSStatus().get_labs()
# ICS router
@app.route('/ics', methods=['GET'])
def get_ics_status():
return ics.ICSStatus().get_labs()
@app.route('/ics/{department}', methods=['GET'])
def get_ics_by_department(department):
return ics.ICSStatus().get_labs_by_department(department)
# athletic router
@app.route('/sports/check', methods=['GET'])
def check_sports():
return athletic.AthleticSchedule().get_last_update()
@app.route('/sports/list', methods=['GET'])
def get_sports_list():
return athletic.AthleticSchedule().get_sports_list()
@app.route('/sports/{sport}', methods=['GET'])
def get_sport(sport):
return athletic.AthleticSchedule().get_sport(sport)
# dining router
@app.route('/dining/{hall}', methods=['GET'])
def get_dining_today(hall):
return dining.Dining().get_menu_today(hall)
@app.route('/dining/{hall}/{date_from}', methods=['GET'])
def get_dining_date(hall, date_from):
return dining.Dining().get_menu_date(hall, date_from, date_from)
@app.route('/dining/{hall}/{date_from}/{date_to}', methods=['GET'])
def get_dining_date_range(hall, date_from, date_to):
return dining.Dining().get_menu_date(hall, date_from, date_to)
# library router
@app.route('/library', methods=['GET'])
def get_all_library():
return library.Library().get_all()
@app.route('/library/{library_id}/{y}/{m}/{d}', methods=['GET'])
def search_library(library_id, y, m, d):
return library.Library().search(library_id, y, m, d)
#daily news router
@app.route('/dailynews', methods=['GET'])
def get_all_news():
return daily.DailyIlliniScraper().get_recent_news()
@app.route('dailynews/{n}', methods=['GET'])
def get_n_news(n):
return daily.DailyIlliniScraper().get_recent_news()[0:n]
#builidng router
@app.route('/buildings', methods=['GET'])
def get_all_buildings():
return buildings.BuildingInfo().get_all_buildings()
@app.route('/buildings/{building_num}', methods=['GET'])
def get_building_by_num(building_num):
return buildings.BuildingInfo().search_by_building_num(int(building_num))
#laundry router
@app.route('/laundry', methods=['GET'])
def get_all_laundry_status():
return laundry.LaundryStatus().get_laundry_status()
#Code below currently not working. To be changed.
'''
@app.route('/laundry/{building_id}', methods=['GET'])
def get_laundry_by_building(building_id):
return laundry.LaundryStatus().get_laundry_by_building(building_id)
@app.route('/laundry/{building_id}/{machine_type}', methods=['GET'])
def get_laundry_by_building_machine(building_id, machine_type):
return laundry.LaundryStatus().get_laundry_by_building_machine(building_id, machine_type)
'''