Created
November 17, 2020 19:18
-
-
Save jph00/c3db65d2fdb75d8c369c45b688630e98 to your computer and use it in GitHub Desktop.
Minimal web server demo in Python (requires fastcore: `pip install fastcore`)
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
from fastcore.utils import * | |
host = 8888,'localhost' | |
sock = start_server(*host) | |
print(f'Serving on {host}...') | |
while True: | |
conn,addr = sock.accept() | |
with conn: | |
data = conn.recv(1024) | |
print(data.decode()) | |
conn.sendall(b"HTTP/1.1 200 OK\n\nHello, World!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment