Skip to content

Instantly share code, notes, and snippets.

@firemanxbr
Created January 25, 2019 08:17
Show Gist options
  • Save firemanxbr/113a874d0703d29ec3f88b69c5989b60 to your computer and use it in GitHub Desktop.
Save firemanxbr/113a874d0703d29ec3f88b69c5989b60 to your computer and use it in GitHub Desktop.
"""
Mock HTTP Server to use in tests
"""
import http.server
import threading
class HandleHTTPServer(http.server.HTTPServer):
"""
Main HTTPServer Class
"""
def __init__(self):
self.server_address = "127.0.0.1"
self.server_port = 8000
self.__class__ = http.server.BaseHTTPRequestHandler
def run(self):
# ADD Thread here
try:
self.serve_forever()
except KeyboardInterrupt:
pass
finally:
self.server_close()
def stop(self):
# ADD Thread here
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment