Skip to content

Instantly share code, notes, and snippets.

@jph00
Created November 17, 2020 19:18
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save jph00/c3db65d2fdb75d8c369c45b688630e98 to your computer and use it in GitHub Desktop.
Save jph00/c3db65d2fdb75d8c369c45b688630e98 to your computer and use it in GitHub Desktop.
Minimal web server demo in Python (requires fastcore: `pip install fastcore`)
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