Last active
January 18, 2022 08:23
-
-
Save tomazas/0282a95e8cdaafc11d721eda1a0522f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# python 2 HTTP GET single-threaded server | |
# input: HTTP XML payload loded from payload.txt file | |
# | |
import SimpleHTTPServer | |
import SocketServer | |
hostName = "localhost" | |
serverPort = 8000 | |
payload = "" | |
with file("payload.txt") as fp: | |
payload = fp.read() | |
class Handler(SimpleHTTPServer.SimpleHTTPRequestHandler): | |
def do_GET(self): | |
self.send_response(200) | |
self.send_header('Content-type', 'application/xml') | |
self.end_headers() | |
self.wfile.write(payload) | |
print "starting %s:%d"%(hostName, serverPort) | |
httpd = SocketServer.TCPServer((hostName, serverPort), Handler) | |
httpd.serve_forever() | |
print "done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment