mirror of
https://github.com/th3r00t/pyShelf.git
synced 2026-04-28 01:59:35 -04:00
Further work on the web server and frontend
This commit is contained in:
@@ -34,18 +34,35 @@ class RequestHandler(BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
# TODO determine how to include stylesheets
|
||||
self.send_response(200)
|
||||
mimetype = mimetypes.guess_type(self.path)
|
||||
self.send_header('Content-type', mimetype)
|
||||
if self.path == '/':
|
||||
self.path = '../static/index.html'
|
||||
mimetype = 'text/html'
|
||||
serve_file = open(self.path[1:]).read()
|
||||
self.send_header('Content-type', mimetype)
|
||||
self.end_headers()
|
||||
self.wfile.write(bytes(serve_file, 'utf-8'))
|
||||
elif self.path.split('.', 1)[1] == 'css':
|
||||
self.path = '../static' + self.path
|
||||
mimetype = 'text/css'
|
||||
serve_file = open(self.path[1:]).read()
|
||||
self.send_header('Content-type', mimetype)
|
||||
self.end_headers()
|
||||
self.wfile.write(bytes(serve_file, 'utf-8'))
|
||||
elif self.path.endswith('.png'):
|
||||
self.path = '../static' + self.path
|
||||
mimetype = 'image/png'
|
||||
serve_file = open(self.path[1:], 'rb') # Important to rb read binary for images
|
||||
self.send_header('Content-type', mimetype)
|
||||
self.end_headers()
|
||||
self.wfile.write(serve_file.read())
|
||||
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'))
|
||||
mimetype = 'text/html'
|
||||
self.send_header('Content-type', mimetype)
|
||||
self.end_headers()
|
||||
try: serve_file.close()
|
||||
except Exception: pass
|
||||
|
||||
class BookServer:
|
||||
"""HTTP Frontend"""
|
||||
|
||||
@@ -1,21 +1,46 @@
|
||||
body{
|
||||
margin: 0px 10px 0px 10px;
|
||||
padding: 0px;
|
||||
background-color: #DCDCDD;
|
||||
color: #46494C
|
||||
}
|
||||
#app{
|
||||
display: grid;
|
||||
grid-template-areas: "app_header"
|
||||
"app_body"
|
||||
"app_footer";
|
||||
grid-template-rows: 5vh 90vh 5vh;
|
||||
max-height: 100%
|
||||
}
|
||||
.app_header{
|
||||
grid-area: app_header;
|
||||
display: grid;
|
||||
grid-template-areas: "title slogan";
|
||||
align-items: center;
|
||||
}
|
||||
.app_hdr{
|
||||
grid-area: title;
|
||||
margin: 0px;
|
||||
font-family: 'Audiowide', cursive;
|
||||
font-size: 25px;
|
||||
text-align: start;
|
||||
}
|
||||
.shadow{
|
||||
text-shadow: #4c5c68 -5px 3px 5px;
|
||||
}
|
||||
.app_subhdr{
|
||||
grid-area: slogan;
|
||||
margin: 0px;
|
||||
font-family: 'Audiowide', cursive;
|
||||
font-size: 18px;
|
||||
text-shadow: #4c5c68 -5px 3px 5px;
|
||||
text-align: end;
|
||||
}
|
||||
.app_body{
|
||||
display: grid;
|
||||
grid-area: app_body;
|
||||
grid-template-columns: 10% 80% 10%;
|
||||
grid-template-areas: "left_col shelf right_col"
|
||||
grid-template-columns: 20% 80%;
|
||||
grid-template-areas: "left_col shelf";
|
||||
}
|
||||
.app_footer{
|
||||
grid-area: app_footer;
|
||||
@@ -24,8 +49,21 @@ body{
|
||||
grid-area: left_col
|
||||
}
|
||||
.shelf{
|
||||
grid-area: shelf
|
||||
grid-area: shelf;
|
||||
margin: 0px auto 0px auto;
|
||||
}
|
||||
.shelf_contents{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
}
|
||||
.right_col{
|
||||
grid-area: right_col
|
||||
}
|
||||
.python_logo{
|
||||
|
||||
}
|
||||
#python_logo{
|
||||
height: 50px;
|
||||
width: 91px;
|
||||
}
|
||||
|
||||
BIN
static/img/py.png
Executable file
BIN
static/img/py.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
0
static/img/shelf.png
Normal file → Executable file
0
static/img/shelf.png
Normal file → Executable file
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
@@ -6,26 +6,26 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link type="text/css" rel="stylesheet" href="/css/main.css" />
|
||||
<title>pyShelf E-Book Server</title>
|
||||
<link href="https://fonts.googleapis.com/css?family=Audiowide&display=swap" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
<div class="app_header" >
|
||||
<h1 class="app_hdr">Welcome to pyShelf</h1>
|
||||
<h2 class="app_subhdr">An Open Source E-book Server!</h2>
|
||||
<h1 class="app_hdr shadow">pyShelf</h1>
|
||||
<h2 class="app_subhdr shadow">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 class="shelf_contents" >Shelf</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="app_footer" >
|
||||
Footer
|
||||
<div class="python_logo" >
|
||||
<img src="/img/py.png" id="python_logo" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user