Created
April 28, 2018 00:32
-
-
Save henry232323/c0a9d959af9b04c3b3c34ad53fc02147 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from http.server import BaseHTTPRequestHandler,HTTPServer | |
PORT_NUMBER = 80 | |
#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(b"<html><title>You just got beaned!</title><body><h1>You just got beaned! This isn't the real Gryphon wifi!</h1><img src=\"http://i0.kym-cdn.com/photos/images/facebook/001/166/993/284.png\" /></body></html>") | |
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() | |
except KeyboardInterrupt: | |
print('^C received, shutting down the web server') | |
server.socket.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment