Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import BaseHTTPServer, SimpleHTTPServer
- import SocketServer
- import argparse
- import thread
- import os.path
- import ssl
- import xml.etree.ElementTree as ET
- class Handler(SimpleHTTPServer.SimpleHTTPRequestHandler):
- actionId = "null"
- windowSessionId = "null"
- def _set_headers(self):
- self.send_response(200)
- self.send_header('Content-type', 'application/xml')
- self.end_headers()
- def do_GET(self):
- self._set_headers()
- self.wfile.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
- "<response>"
- "<actionId>" + self.actionId + "</actionId>"
- "<windowSessionId>" + self. windowSessionId + "</windowSessionId>"
- "</response>")
- def do_POST(self):
- self._set_headers()
- request_headers = self.headers
- content_length = request_headers.getheaders('content-length')
- length = int(content_length[0]) if content_length else 0
- print(request_headers)
- xml = self.rfile.read(length)
- print(xml)
- root = ET.fromstring(xml)
- messageId = root.find("{http://www.playtech.com/services/login}messageId").text
- flowId = root.find("{playtech.com/galaxy/core}flow").get('id')
- actionID = root.find("{http://www.playtech.com/services/login}actionId").text
- self.actionId = actionID
- print("MessageId: " + messageId)
- print("FlowId: " + flowId)
- print("ActionId: " + actionID)
- self.wfile.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns34:notifyActionOpenResponse xmlns:ns34=\"http://www.playtech.com/services/login\" xmlns:ns4=\"playtech.com/galaxy/core\" xmlns:ns31=\"http://www.playtech.com/services/common\"><ns4:flow id=\"" + flowId + "\"/><ns34:messageId>" + messageId + "</ns34:messageId><ns34:errorCode>0</ns34:errorCode></ns34:notifyActionOpenResponse>")
- def http_server(port, handler):
- httpd = SocketServer.TCPServer(("", port), handler)
- httpd.serve_forever()
- # Parse command-line arguments
- parser = argparse.ArgumentParser(description='Simple HTTP web server with HTTPS support which logs all incoming requests and collects some stats.')
- parser.add_argument('--http_port', type=int, dest='http_port', default=8000, help='Application HTTP port number')
- args = parser.parse_args()
- if __name__=='__main__':
- http_server(args.http_port, Handler)
- # thread.start_new_thread(https_server, (args.https_port, Handler, args.cert))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement