Kadinsamson / Web_server

Creating a sample web server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Developing a Simple Webserver

AIM:

To develop a simple webserver to serve html pages.

DESIGN STEPS:

Step 1:

HTML content creation

Step 2:

Design of webserver workflow

Step 3:

Implementation using Python code

Step 4:

Serving the HTML pages.

Step 5:

Testing the webserver

PROGRAM:


from http.server import HTTPServer, BaseHTTPRequestHandler
content = """
<!DOCTYPE html>
<html>
<head>
<title>My webserver</title>
</head>
<body>
<h1>Name: KADIN SAMSON</h1>
<h2>REF NO: 21001514</h2>
<h2>Dept:Artificial Intelligenece and Data science</h2>
</body>

</html>

"""
class myhandler(BaseHTTPRequestHandler):
    def do_GET(self):
        print("request received")
        self.send_response(200)
        self.send_header('content-type', 'text/html; charset=utf-8')
        self.end_headers()
        self.wfile.write(content.encode())
server_address = ('',8080)
httpd = HTTPServer(server_address,myhandler)
print("my webserver is running...")
httpd.serve_forever()

OUTPUT:

github logo

RESULT:

THE WEB SERVER HAS BEEN SUCCESSFULLY CREATED

About

Creating a sample web server

License:GNU General Public License v3.0


Languages

Language:Python 83.6%Language:HTML 16.4%