Skip to content

Instantly share code, notes, and snippets.

@carlos-a-g-h
Created October 22, 2022 21:32
Show Gist options
  • Save carlos-a-g-h/604075b1db1f6d53d1bedf2d29e0889a to your computer and use it in GitHub Desktop.
Save carlos-a-g-h/604075b1db1f6d53d1bedf2d29e0889a to your computer and use it in GitHub Desktop.
#!/usr/bin/python3.9
# Extremely simple webserver made with the stdlib just for testing purposes
import time
import sys
from http.server import BaseHTTPRequestHandler, HTTPServer
try:
port=int(sys.argv[1])
except:
port=80
class MyServer(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header("Content-type","text/plain")
self.end_headers()
self.wfile.write(bytes("It's working...","utf-8"))
webServer = HTTPServer(("localhost",port),MyServer)
webServer.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment