started server
This commit is contained in:
parent
d9166098be
commit
0c06bc01dc
23
public/index.html
Normal file
23
public/index.html
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Why Frontend Development Sucks</title>
|
||||||
|
<link rel="stylesheet" href="styles.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>Front-end Development is the Worst</h1>
|
||||||
|
<p>
|
||||||
|
Look, front-end development is for script kiddies and soydevs who can't handle the real programming. I mean,
|
||||||
|
it's just a bunch of divs and spans, right? And css??? It's like, "Oh, I want this to be red, but not thaaaaat
|
||||||
|
red." What a joke.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Real programmers code, not silly markup languages. They code on Arch Linux, not Mac OS, and certainly not
|
||||||
|
Windows. They use Vim, not VS Code. They use C, not HTML. Come to the <a
|
||||||
|
href="https://www.boot.dev">backend</a>, where the real programming
|
||||||
|
happens.
|
||||||
|
</p>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
27
public/styles.css
Normal file
27
public/styles.css
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
body {
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
line-height: 1.6;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
background-color: #1f1f23;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
max-width: 600px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
color: #ffffff;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
color: #999999;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: #6568ff;
|
||||||
|
}
|
40
server.py
Normal file
40
server.py
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import os
|
||||||
|
import argparse
|
||||||
|
from http.server import HTTPServer, SimpleHTTPRequestHandler
|
||||||
|
|
||||||
|
|
||||||
|
class CORSHTTPRequestHandler(SimpleHTTPRequestHandler):
|
||||||
|
def end_headers(self):
|
||||||
|
self.send_header("Access-Control-Allow-Origin", "*")
|
||||||
|
self.send_header("Access-Control-Allow-Methods", "GET, OPTIONS")
|
||||||
|
self.send_header("Access-Control-Allow-Headers", "*")
|
||||||
|
super().end_headers()
|
||||||
|
|
||||||
|
def do_OPTIONS(self):
|
||||||
|
self.send_response(200, "OK")
|
||||||
|
self.end_headers()
|
||||||
|
|
||||||
|
|
||||||
|
def run(
|
||||||
|
server_class=HTTPServer,
|
||||||
|
handler_class=CORSHTTPRequestHandler,
|
||||||
|
port=8000,
|
||||||
|
directory=None,
|
||||||
|
):
|
||||||
|
if directory: # Change the current working directory if directory is specified
|
||||||
|
os.chdir(directory)
|
||||||
|
server_address = ("", port)
|
||||||
|
httpd = server_class(server_address, handler_class)
|
||||||
|
print(f"Serving HTTP on http://localhost:{port} from directory '{directory}'...")
|
||||||
|
httpd.serve_forever()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
parser = argparse.ArgumentParser(description="HTTP Server with CORS")
|
||||||
|
parser.add_argument(
|
||||||
|
"--dir", type=str, help="Directory to serve files from", default="."
|
||||||
|
)
|
||||||
|
parser.add_argument("--port", type=int, help="Port to serve HTTP on", default=8888)
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
run(port=args.port, directory=args.dir)
|
Loading…
Reference in New Issue
Block a user