diff --git "a/lib/\\" "b/lib/\\" deleted file mode 100644 index 77dfd98..0000000 --- "a/lib/\\" +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/python -import os -import zipfile -from http.server import HTTPServer, BaseHTTPRequestHandler -from config import Config -from lib.library import Catalogue -from lib.storage import Storage -config = Config() -Storage = Storage() - - -class InitFiles: - """First run file creation operations""" - def __init__(self, file_array): - print("Begining creation of file structure") - for _pointer in file_array: - if not os.path.isfile(_pointer): - self.CreateFile(_pointer) - - def CreateFile(self, _pointer): - """Create the file""" - if not os.path.isdir(os.path.split(_pointer)[0]): - os.mkdir(os.path.split(_pointer)[0]) - f = open(_pointer, "w+") - f.close() - - -class BookServer: - """HTTP Frontend""" - def __init__(self): - self.server_address = ('', 8000) - self.handler = 'BaseHTTPRequestHandler' - - def close_prompt(self): - close = input("Close Server? y/n") - if close == 'y': - self.close() - return True - else: - self.close_prompt() - - def run(self): - self.httpd = HTTPServer(self.server_address, self.handler) - try: - self.httpd.serve_forever() - self.httpd.handle_request() - if self.close_prompt() == True: - pass - except Exception: - self.close() - return False - - def close(self): - try: - self.httpd.server_close() - return True - except Exception: - return False - diff --git a/lib/pyShelf.py b/lib/pyShelf.py index a147302..ecd7c8f 100755 --- a/lib/pyShelf.py +++ b/lib/pyShelf.py @@ -1,4 +1,5 @@ #!/usr/bin/python +import mimetypes import os import zipfile from http.server import BaseHTTPRequestHandler, HTTPServer @@ -33,13 +34,17 @@ class RequestHandler(BaseHTTPRequestHandler): def do_GET(self): # TODO determine how to include stylesheets self.send_response(200) - self.end_headers() + mimetype = mimetypes.guess_type(self.path) + self.send_header('Content-type', mimetype) if self.path == '/': self.path = '../static/index.html' - serve_file = open(self.path[1:]).read() + elif self.path.split('.', 1)[1] == 'css': + self.path = '../static' + self.path else: self.send_response(404) serve_file = "File Not Found" + serve_file = open(self.path[1:]).read() + self.end_headers() self.wfile.write(bytes(serve_file, 'utf-8')) class BookServer: diff --git a/static/css/main.css b/static/css/main.css index 20e1364..30e8f12 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -1,3 +1,31 @@ body{ - background-color: #f1f1 + margin: 0px 10px 0px 10px; + padding: 0px; +} +#app{ + display: grid; + grid-template-areas: "app_header" + "app_body" + "app_footer"; +} +.app_header{ + grid-area: app_header; +} +.app_body{ + display: grid; + grid-area: app_body; + grid-template-columns: 10% 80% 10%; + grid-template-areas: "left_col shelf right_col" +} +.app_footer{ + grid-area: app_footer; +} +.left_col{ + grid-area: left_col +} +.shelf{ + grid-area: shelf +} +.right_col{ + grid-area: right_col } diff --git a/static/img/shelf.png b/static/img/shelf.png new file mode 100644 index 0000000..fdffe48 Binary files /dev/null and b/static/img/shelf.png differ diff --git a/static/index.html b/static/index.html index 0e10aad..734f2e7 100644 --- a/static/index.html +++ b/static/index.html @@ -9,8 +9,24 @@