diff options
author | Matt Strapp <strap012@umn.edu> | 2021-04-26 17:06:13 -0500 |
---|---|---|
committer | Matt Strapp <strap012@umn.edu> | 2021-04-26 17:06:13 -0500 |
commit | e58a60ed18bde5db28ba96910df518a61b3999b2 (patch) | |
tree | 3667c6271681ecdf584d5f619246b25e3b26b01f /python/dotsandboxes/dotsandboxesserver.py | |
parent | Finally fix (diff) | |
download | csci4511w-e58a60ed18bde5db28ba96910df518a61b3999b2.tar csci4511w-e58a60ed18bde5db28ba96910df518a61b3999b2.tar.gz csci4511w-e58a60ed18bde5db28ba96910df518a61b3999b2.tar.bz2 csci4511w-e58a60ed18bde5db28ba96910df518a61b3999b2.tar.lz csci4511w-e58a60ed18bde5db28ba96910df518a61b3999b2.tar.xz csci4511w-e58a60ed18bde5db28ba96910df518a61b3999b2.tar.zst csci4511w-e58a60ed18bde5db28ba96910df518a61b3999b2.zip |
Refactor jsut about everything
Diffstat (limited to 'python/dotsandboxes/dotsandboxesserver.py')
-rw-r--r-- | python/dotsandboxes/dotsandboxesserver.py | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/python/dotsandboxes/dotsandboxesserver.py b/python/dotsandboxes/dotsandboxesserver.py deleted file mode 100644 index 1b66372..0000000 --- a/python/dotsandboxes/dotsandboxesserver.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python3 -# encoding: utf-8 -""" -dotsandboxesserver.py - -Template for the Machine Learning Project course at KU Leuven (2017-2018) -of Hendrik Blockeel and Wannes Meert. - -Copyright (c) 2018 KU Leuven. All rights reserved. -""" - -import sys -import argparse -import logging -import http.server -import socketserver -import json - -logger = logging.getLogger(__name__) - - -class RequestHandler(http.server.SimpleHTTPRequestHandler): - def do_GET(self): - if self.path == "/": - self.send_response(302) - self.send_header("Location", "static/dotsandboxes.html") - self.end_headers() - return super().do_GET() - - def do_PUT(self): - response = { - 'result': 'ok' - } - self.send_response(200) - self.send_header('Content-type', 'application/json') - self.end_headers() - self.wfile.write(json.dumps(response).encode()) - - -def start_server(port): - with socketserver.TCPServer(("", port), RequestHandler) as httpd: - print("Running on http://127.0.0.1:{}".format(port)) - httpd.serve_forever() - - -def main(argv=None): - parser = argparse.ArgumentParser(description='Start server to play Dots and Boxes') - parser.add_argument('--verbose', '-v', action='count', default=0, help='Verbose output') - parser.add_argument('--quiet', '-q', action='count', default=0, help='Quiet output') - parser.add_argument('port', metavar='PORT', type=int, help='Port to use for server') - args = parser.parse_args(argv) - - logger.setLevel(max(logging.INFO - 10 * (args.verbose - args.quiet), logging.DEBUG)) - logger.addHandler(logging.StreamHandler(sys.stdout)) - - start_server(args.port) - - -if __name__ == "__main__": - sys.exit(main()) |