summaryrefslogtreecommitdiffstats
path: root/lib.py
diff options
context:
space:
mode:
authorMax Bringemo <maxbr167@student.liu.se>2020-12-14 21:08:59 +0100
committerStefan Hansson <steha708@student.liu.se>2020-12-14 21:08:59 +0100
commit325f2078c37bc073fff964946a2ce643d181fa3d (patch)
treeba07a6e94989ef44335619f1547e521280461a61 /lib.py
parent542aa50ad4bae5e719bcffc9265a15824a444284 (diff)
downloadtdde25-325f2078c37bc073fff964946a2ce643d181fa3d.tar.gz
Grid search
Diffstat (limited to 'lib.py')
-rw-r--r--lib.py14
1 files changed, 7 insertions, 7 deletions
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 "<code>{}</code>".format(code).replace("\n", "\n<br>") \
- .replace(" ", "&nbsp;")
+ .replace(" ", "&nbsp;")
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