Last active
March 8, 2017 14:23
-
-
Save facert/c24f1ecf8a09d9ab43215e452d4e5ac7 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
# coding: utf-8 | |
import BaseHTTPServer | |
class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler): | |
def do_FUCK(s): | |
s.send_response(200) | |
s.send_header("Content-type", "text/html") | |
s.end_headers() | |
s.wfile.write("just a kidding\n") | |
def do_GET(s): | |
"""Respond to a GET request.""" | |
s.send_response(200) | |
s.send_header("Content-type", "text/html") | |
s.end_headers() | |
s.wfile.write("<html><head><title>Title goes here.</title></head>") | |
s.wfile.write("<body><p>This is a test.</p>") | |
s.wfile.write("</body></html>") | |
def do_POST(s): | |
"""Respond to a GET request.""" | |
s.send_response(233) | |
s.send_header("Content-type", "text/html") | |
s.end_headers() | |
s.wfile.write("服务器有小情绪了╭(╯^╰)╮\n") | |
if __name__ == '__main__': | |
server_class = BaseHTTPServer.HTTPServer | |
httpd = server_class(("127.0.0.1", 8000), MyHandler) | |
try: | |
httpd.serve_forever() | |
except KeyboardInterrupt: | |
pass | |
httpd.server_close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment