Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added 1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
80 changes: 79 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# EX01 Developing a Simple Webserver

# Date:
# Date:20-09-2025
# AIM:
To develop a simple webserver to serve html pages and display the configuration details of laptop.

Expand All @@ -21,6 +21,84 @@ Serving the HTML pages.
Testing the webserver.

# PROGRAM:
```
from django.shortcuts import render
from http.server import HTTPServer,BaseHTTPRequestHandler
content = '''
from django.shortcuts import render
from http.server import HTTPServer,BaseHTTPRequestHandler
content = '''<!DOCTYPE html>
<html>
<head>
<title>My Simple Web Server Page</title>
<style>
body {
background-color: lightblue;
font-family: Arial, sans-serif;
text-align: center;
margin: 0;
padding: 0;
}
header {
background-color: darkblue;
color: white;
padding: 20px;
font-size: 24px;
}
main {
margin-top: 40px;
}
p {
font-size: 18px;
color: darkgreen;
}
button {
background-color: orange;
border: none;
padding: 10px 20px;
font-size: 16px;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: red;
color: white;
}

</style>
</head>
<body>
<header>
Welcome to My Simple Web Page
</header>

<main>
<h1>Hello, World!</h1>
<p>This is my first colorful webpage served with a simple web server.</p>
<button onclick="alert('You clicked me!')">Click Me</button>
</main>


</body>
</html>
'''

class MyServer(BaseHTTPRequestHandler):
def do_GET(self):
print("Get request received..." )
self.send_response(200)
self.send_header("content-type", "text/html")
self.end_headers()
self.wfile.write(content.encode())
print("This is my webserver")
server_address =('', 8000)
httpd = HTTPServer(server_address,MyServer)
httpd.serve_forever()
```
# OUTPUT:
<img width="1918" height="836" alt="image" src="https://github.com/user-attachments/assets/154b5b16-8f87-4dcd-b1f4-f8dc30c08aeb" />

![alt text](2.png)

# RESULT:
The program for implementing simple webserver is executed successfully.
69 changes: 69 additions & 0 deletions new.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
from django.shortcuts import render
from http.server import HTTPServer,BaseHTTPRequestHandler
content = '''<!DOCTYPE html>
<html>
<head>
<title>My Simple Web Server Page</title>
<style>
body {
background-color: lightblue;
font-family: Arial, sans-serif;
text-align: center;
margin: 0;
padding: 0;
}
header {
background-color: darkblue;
color: white;
padding: 20px;
font-size: 24px;
}
main {
margin-top: 40px;
}
p {
font-size: 18px;
color: darkgreen;
}
button {
background-color: orange;
border: none;
padding: 10px 20px;
font-size: 16px;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: red;
color: white;
}

</style>
</head>
<body>
<header>
Welcome to My Simple Web Page
</header>

<main>
<h1>Hello, World!</h1>
<p>This is my first colorful webpage served with a simple web server.</p>
<button onclick="alert('You clicked me!')">Click Me</button>
</main>


</body>
</html>
'''

class MyServer(BaseHTTPRequestHandler):
def do_GET(self):
print("Get request received..." )
self.send_response(200)
self.send_header("content-type", "text/html")
self.end_headers()
self.wfile.write(content.encode())
print("This is my webserver")
server_address =('', 8000)
httpd = HTTPServer(server_address,MyServer)
httpd.serve_forever()
1 change: 1 addition & 0 deletions simple_web_server
Submodule simple_web_server added at e82571