JEGADEESH07 / 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 display top 5 programming frameworks.

DESIGN STEPS:

Step 1:

HTML content creation is done

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>
<titlt>MY WEBSERVER</title>
</head>
<body>
<h1>WELCOME TO MY SIMPLE WEBSERVER</h1>
</body>
</html>
'''

class MyServer(BaseHTTPRequestHandler):
    def do_GET(self):
        print("Get request received...")
        self.send_response(200)  
        self.send_header('content-type', 'text/html; charset=utf-8')      
        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:

output output

RESULT:

The program is executed succesfully

About

Creating a sample web server

License:GNU General Public License v3.0


Languages

Language:Python 100.0%