Esempio n. 1
0
 def application(self, request):
     dispatcher.add_class(HyperFlexHandler)        
     response_json = JSONRPCResponseManager.handle(
             request.data, dispatcher)
     headers = Headers()
     headers.add('Access-Control-Allow-Origin', '*')
     headers.add('Access-Control-Allow-Headers', 'Content-Type')
     return Response(response_json.json, mimetype='application/json',headers=headers)
Esempio n. 2
0
# coding=utf-8

from __future__ import print_function

import logging
import socket
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
from SocketServer import ThreadingMixIn

from jsonrpc import JSONRPCResponseManager, dispatcher

from MSISDN import Parser

logging.basicConfig(level=logging.DEBUG)

dispatcher.add_class(Parser)


class Handler(BaseHTTPRequestHandler):
    def __init__(self, request, client_address, server):
        self.logger = logging.getLogger('Handler')
        self.logger.debug('__init__')
        BaseHTTPRequestHandler.__init__(self, request, client_address, server)

    def do_POST(self):
        self.logger.debug('do_POST')
        content_len = int(self.headers.getheader('content-length'))
        post_body = self.rfile.read(content_len)
        self.send_response(200)
        self.end_headers()