Skip to content

Instantly share code, notes, and snippets.

@javascripto
Created January 28, 2023 12:52
Show Gist options
  • Select an option

  • Save javascripto/4b52ac03c3594630b4836701b34a65d5 to your computer and use it in GitHub Desktop.

Select an option

Save javascripto/4b52ac03c3594630b4836701b34a65d5 to your computer and use it in GitHub Desktop.
from http.server import HTTPServer, BaseHTTPRequestHandler
class RequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('Content-Type', 'text/html')
self.end_headers()
file = open('index.html', 'r')
index = file.read()
file.close()
self.wfile.write(index.encode())
if __name__ == '__main__':
httpd = HTTPServer(('localhost', 8080), RequestHandler)
print('Running on http://localhost:8080')
httpd.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment