Skip to content

Instantly share code, notes, and snippets.

@facert
Last active March 8, 2017 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save facert/c24f1ecf8a09d9ab43215e452d4e5ac7 to your computer and use it in GitHub Desktop.
Save facert/c24f1ecf8a09d9ab43215e452d4e5ac7 to your computer and use it in GitHub Desktop.
# 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