forked from kgilbert-cmu/basketball-gm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runserver.py
executable file
·59 lines (45 loc) · 1.25 KB
/
runserver.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
#!/usr/bin/env python
# This should be kept in sync with .htaccess so either can be used
import web
urls = (
'/(css/.*)', 'static',
'/(data/.*)', 'static',
'/(docs.*)', 'static',
'/(gen/.*)', 'static',
'/(ico/.*)', 'static',
'/(img/.*)', 'static',
'/(js/.*)', 'static',
'/(templates/.*)', 'static',
'/test', 'test',
'/test_case', 'test_case',
'/.*', 'index'
)
app = web.application(urls, globals())
class static:
def GET(self, filename):
if filename.endswith('.css'):
web.header('Content-type', 'text/css')
elif filename.endswith('.txt'):
web.header('Content-type', 'text/plain')
elif filename.endswith('.js'):
web.header('Content-type', 'text/javascript')
elif filename.endswith('/'):
filename += 'index.html'
elif not '.' in filename:
filename += '/index.html'
f = open(filename)
return f.read()
class index:
def GET(self):
f = open('index.html')
return f.read()
class test:
def GET(self):
f = open('test.html')
return f.read()
class test_case:
def GET(self):
f = open('test_case.html')
return f.read()
if __name__ == '__main__':
app.run()