Skip to content

Instantly share code, notes, and snippets.

@mathiasfls
Forked from jph00/webserver.py
Created November 18, 2020 11:50
Show Gist options
  • Select an option

  • Save mathiasfls/d6d4ac2b82f8bc7c4463f596dbd092dc to your computer and use it in GitHub Desktop.

Select an option

Save mathiasfls/d6d4ac2b82f8bc7c4463f596dbd092dc 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