1
0
mirror of https://github.com/webrecorder/pywb.git synced 2025-03-16 00:24:48 +01:00
pywb/rezag/app.py
Ilya Kreymer 68090d00c1 add routing setup via app.py
add full test suite for handlers and responseloaders, as well as timeouts
2016-02-28 14:33:08 -08:00

32 lines
875 B
Python

from rezag.inputrequest import WSGIInputRequest, POSTInputRequest
from bottle import route, request, response, default_app
def add_route(path, handler):
def debug(func):
def do_d():
try:
return func()
except Exception:
import traceback
traceback.print_exc()
return do_d
def direct_input_request():
params = dict(request.query)
params['_input_req'] = WSGIInputRequest(request.environ)
return handler(params)
def post_fullrequest():
params = dict(request.query)
params['_input_req'] = POSTInputRequest(request.environ)
return handler(params)
route(path + '/postreq', method=['POST'], callback=debug(post_fullrequest))
route(path, method=['ANY'], callback=debug(direct_input_request))
application = default_app()