-
-
Save storenth/5bee17e67968d37390ab22f918eaf0b1 to your computer and use it in GitHub Desktop.
An attempt to create the simplest HTTP Hello world in Python3
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
import http.server | |
import socketserver | |
from http import HTTPStatus | |
class Handler(http.server.SimpleHTTPRequestHandler): | |
def do_GET(self): | |
self.send_response(HTTPStatus.OK) | |
self.end_headers() | |
self.wfile.write(b'Hello world') | |
httpd = socketserver.TCPServer(('', 8000), Handler) | |
httpd.serve_forever() | |
# python3 server.py | |
# 127.0.0.1 - - [11/Apr/2017 11:36:49] "GET / HTTP/1.1" 200 - | |
# http :8000 | |
''' | |
HTTP/1.0 200 OK | |
Date: Tue, 11 Apr 2017 15:36:49 GMT | |
Server: SimpleHTTP/0.6 Python/3.5.2 | |
Hello world | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment