Skip to content

Instantly share code, notes, and snippets.

@MichaelStett
Created May 16, 2023 11:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MichaelStett/4390bea05d524498b0888d0c80172da9 to your computer and use it in GitHub Desktop.
Save MichaelStett/4390bea05d524498b0888d0c80172da9 to your computer and use it in GitHub Desktop.
Create server on given ip
import http.server
import socketserver
import sys
PORT = int(sys.argv[1])
print(f"Port {PORT}")
if PORT == "":
exit(-1)
Handler = http.server.SimpleHTTPRequestHandler
with socketserver.TCPServer(("", PORT), Handler) as httpd:
print(f"Serving on port {PORT}")
httpd.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment