Created
February 5, 2014 20:49
-
-
Save astrofrog/8832745 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
import BaseHTTPServer | |
def run_while_true(server_class=BaseHTTPServer.HTTPServer, | |
handler_class=BaseHTTPServer.BaseHTTPRequestHandler): | |
""" | |
This assumes that keep_running() is a function of no arguments which | |
is tested initially and after each request. If its return value | |
is true, the server continues. | |
""" | |
server_address = ('', 8000) | |
httpd = server_class(server_address, handler_class) | |
while True: | |
try: | |
httpd.handle_request() | |
return | |
except: | |
pass | |
run_while_true() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment