Create myServer.py

This commit is contained in:
siwinter 2019-10-24 12:54:29 +02:00 committed by GitHub
parent c6ed19e2ef
commit 5748f1b182
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

27
myServer.py Normal file
View file

@ -0,0 +1,27 @@
#!/usr/bin/python
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer
PORT_NUMBER = 8080
#This class will handles any incoming request from
#the browser
class myHandler(BaseHTTPRequestHandler):
#Handler for the GET requests
def do_GET(self):
self.send_response(200)
self.send_header('Content-type','text/html')
self.end_headers()
# Send the html message
self.wfile.write("Hello World !")
print self.path
return
try:
#Create a web server and define the handler to manage the
#incoming request
server = HTTPServer(('', PORT_NUMBER), myHandler)
print 'Started httpserver on port ' , PORT_NUMBER
#Wait forever for incoming htto requests
server.serve_forever()