This repository was archived by the owner on Aug 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
44 lines (36 loc) · 1.25 KB
/
app.py
File metadata and controls
44 lines (36 loc) · 1.25 KB
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
#!/usr/bin/env python3.9
# from livereload import Server
import web
import json
import model
import course
import courses
import professor
import professors
import grades
import search
urls = (
'/', 'Index',
'/v1', 'VersionOne',
'/v1/course', course.Course,
'/v1/courses', courses.Courses,
'/v1/professor', professor.Professor,
'/v1/professors', professors.Professors,
'/v1/grades', grades.Grades,
'/v1/search', search.Search
)
web.config.debug = False
app = web.application(urls, globals())
render = web.template.render('static', globals={'str': str})
class Index:
def GET(self):
model.insert_view(web.ctx.host + web.ctx.fullpath, web.ctx.status, web.ctx.ip, web.ctx.env['HTTP_USER_AGENT'] if 'HTTP_USER_AGENT' in web.ctx.env else None, "GET")
return render.index()
class VersionOne:
def GET(self):
model.insert_view(web.ctx.host + web.ctx.fullpath, web.ctx.status, web.ctx.ip, web.ctx.env['HTTP_USER_AGENT'] if 'HTTP_USER_AGENT' in web.ctx.env else None, "GET")
web.header('Content-Type', 'application/json')
web.header('Access-Control-Allow-Origin', '*')
return json.dumps({'version': 1, 'documentation': 'https://api.planetterp.com'})
if __name__ == "__main__":
app.run()