From 325f2078c37bc073fff964946a2ce643d181fa3d Mon Sep 17 00:00:00 2001 From: Max Bringemo Date: Mon, 14 Dec 2020 21:08:59 +0100 Subject: Grid search --- lib.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lib.py') diff --git a/lib.py b/lib.py index 2ceb51d..8a31276 100644 --- a/lib.py +++ b/lib.py @@ -23,7 +23,7 @@ def format_py(code): return highlight(code, PythonLexer(), formatter) else: return "{}".format(code).replace("\n", "\n
") \ - .replace(" ", " ") + .replace(" ", " ") def find_get(path): @@ -61,7 +61,7 @@ def get_relative_path(): def read_html(relative_file_path): """ Reads the html file on the file location provided and injects any external files (marked with {{file_path}} ) - that may be present. Returns the html content as a string. + that may be present. Returns the html content as a string. Example: >>> html_string = read_html('templates/index.html') @@ -75,7 +75,7 @@ def read_html(relative_file_path): def inject_external_files(html_content): - """ [Internal] - Replaces {{ 'file_path' }} with the file content of that file + """ [Internal] - Replaces {{ 'file_path' }} with the file content of that file pat. Useful for seperation of javascript and css files. Uses regex to capture the pattern. Here is a link to see how it works: https://regex101.com/r/v917NK/2 @@ -102,8 +102,8 @@ def inject_external_files(html_content): def post(route='/'): """ A decorator that takes in the route path as argument, and then - puts the post handler in the dictionary, with the route as a key. - The handler will receive one `str` argument called 'body', + puts the post handler in the dictionary, with the route as a key. + The handler will receive one `str` argument called 'body', where the body of the post request will exist. """ def decorator(handler_function): @@ -134,7 +134,7 @@ class Handler(BaseHTTPRequestHandler): def do_GET(self): """ Tries to find the handler for this GET request. The handler can - return either `bytes` or `str`. + return either `bytes` or `str`. """ status, res = find_get(self.path) self.send_response(status) @@ -162,4 +162,4 @@ def run_server(port=8314): server_address = ('127.0.0.1', port) # Should make the port a command line argument server = HTTPServer(server_address, Handler) print('Starting server on http://{}:{}.'.format(*server_address)) - server.serve_forever() + server.serve_forever() \ No newline at end of file -- cgit v1.2.1