|
@@ -4,6 +4,7 @@ import errno
|
|
|
import json
|
|
import json
|
|
|
import os
|
|
import os
|
|
|
from os import path
|
|
from os import path
|
|
|
|
|
+import traceback
|
|
|
import warnings
|
|
import warnings
|
|
|
|
|
|
|
|
warnings.filterwarnings('ignore', 'libevent')
|
|
warnings.filterwarnings('ignore', 'libevent')
|
|
@@ -26,16 +27,22 @@ def main():
|
|
|
server.serve_forever()
|
|
server.serve_forever()
|
|
|
|
|
|
|
|
def application(environ, start_response):
|
|
def application(environ, start_response):
|
|
|
- split = environ['PATH_INFO'][1:].split('/')
|
|
|
|
|
- if split[0] == 'v1':
|
|
|
|
|
- handler = handlers.get(split[2])
|
|
|
|
|
- if handler:
|
|
|
|
|
- start_response('200 OK', [('Content-type', 'text/plain')])
|
|
|
|
|
- return [handler(split, environ)]
|
|
|
|
|
|
|
+ try:
|
|
|
|
|
+ split = environ['PATH_INFO'][1:].split('/')
|
|
|
|
|
+ if split[0] == 'v1':
|
|
|
|
|
+ handler = handlers.get(split[2])
|
|
|
|
|
+ if handler:
|
|
|
|
|
+ body = handler(split, environ)
|
|
|
|
|
+ start_response('200 OK', [('Content-type', 'text/plain')])
|
|
|
|
|
+ return [body]
|
|
|
|
|
+ else:
|
|
|
|
|
+ print 'no handler for', split
|
|
|
else:
|
|
else:
|
|
|
- print 'no handler for', split
|
|
|
|
|
- else:
|
|
|
|
|
- print 'split was', split
|
|
|
|
|
|
|
+ print 'split was', split
|
|
|
|
|
+ except:
|
|
|
|
|
+ traceback.print_exc()
|
|
|
|
|
+ start_response('500 Internal Server Error', [('Content-type', 'text/plain')])
|
|
|
|
|
+ return ['ruh roh']
|
|
|
|
|
|
|
|
def get_data(split, environ):
|
|
def get_data(split, environ):
|
|
|
group = int(split[1])
|
|
group = int(split[1])
|