mirror of
https://github.com/th3r00t/pyShelf.git
synced 2026-04-28 01:59:35 -04:00
Began laying out frontend interface
This commit is contained in:
59
lib/\
59
lib/\
@@ -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
|
|
||||||
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
import mimetypes
|
||||||
import os
|
import os
|
||||||
import zipfile
|
import zipfile
|
||||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||||
@@ -33,13 +34,17 @@ class RequestHandler(BaseHTTPRequestHandler):
|
|||||||
def do_GET(self):
|
def do_GET(self):
|
||||||
# TODO determine how to include stylesheets
|
# TODO determine how to include stylesheets
|
||||||
self.send_response(200)
|
self.send_response(200)
|
||||||
self.end_headers()
|
mimetype = mimetypes.guess_type(self.path)
|
||||||
|
self.send_header('Content-type', mimetype)
|
||||||
if self.path == '/':
|
if self.path == '/':
|
||||||
self.path = '../static/index.html'
|
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:
|
else:
|
||||||
self.send_response(404)
|
self.send_response(404)
|
||||||
serve_file = "File Not Found"
|
serve_file = "File Not Found"
|
||||||
|
serve_file = open(self.path[1:]).read()
|
||||||
|
self.end_headers()
|
||||||
self.wfile.write(bytes(serve_file, 'utf-8'))
|
self.wfile.write(bytes(serve_file, 'utf-8'))
|
||||||
|
|
||||||
class BookServer:
|
class BookServer:
|
||||||
|
|||||||
@@ -1,3 +1,31 @@
|
|||||||
body{
|
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
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
static/img/shelf.png
Normal file
BIN
static/img/shelf.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@@ -9,8 +9,24 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
<h1 class="app_hdr">Welcome to pyShelf</h1>
|
<div class="app_header" >
|
||||||
<h2 class="app_subhdr">An Open Source E-book Server!</h2>
|
<h1 class="app_hdr">Welcome to pyShelf</h1>
|
||||||
|
<h2 class="app_subhdr">An Open Source E-book Server!</h2>
|
||||||
|
</div>
|
||||||
|
<div class="app_body" >
|
||||||
|
<div class="left_col">
|
||||||
|
left_col
|
||||||
|
</div>
|
||||||
|
<div class="shelf">
|
||||||
|
shelf
|
||||||
|
</div>
|
||||||
|
<div class="right_col" >
|
||||||
|
right_col
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="app_footer" >
|
||||||
|
Footer
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user