Compare commits

...
Sign in to create a new pull request.

2 commits

Author SHA1 Message Date
SyncIDE User
64297d2e98 added text 2026-04-02 18:41:01 +00:00
SyncIDE Test
cfd79674f6 added basic website 2026-04-02 18:08:06 +00:00

53
main.py
View file

@ -1,6 +1,53 @@
def main():
print("Hello from syncide-test!")
from http.server import BaseHTTPRequestHandler, HTTPServer
class MyServerHandler(BaseHTTPRequestHandler):
def do_GET(self):
if self.path == '/':
self.send_response(200)
self.send_header("Content-type", "text/html")
self.end_headers()
html = """
<html>
<head><title>Home</title></head>
<body>
<h1>Welcome to the Home Page</h1>
<p>This is a simple preview. wow coool</p>
<a href="subpage">Go to Subpage</a>
</body>
</html>
"""
self.wfile.write(html.encode("utf-8"))
elif self.path == '/subpage':
self.send_response(200)
self.send_header("Content-type", "text/html")
self.end_headers()
html = """
<html>
<head><title>Subpage</title></head>
<body>
<h1>This is the Subpage!</h1>
<a href=".">Go back to Home</a>
</body>
</html>
"""
self.wfile.write(html.encode("utf-8"))
else:
self.send_response(404)
self.send_header("Content-type", "text/html")
self.end_headers()
self.wfile.write(b"<h1>404 Not Found</h1>")
if __name__ == "__main__":
main()
port = 8080
server = HTTPServer(("0.0.0.0", port), MyServerHandler)
print(f"Server running at http://0.0.0.0:{port}")
try:
server.serve_forever()
except KeyboardInterrupt:
print("\nShutting down server.")
server.server_close()