Skip to content

Instantly share code, notes, and snippets.

@phrawzty
Last active July 7, 2025 11:59
Show Gist options
  • Save phrawzty/62540f146ee5e74ea1ab to your computer and use it in GitHub Desktop.
Save phrawzty/62540f146ee5e74ea1ab to your computer and use it in GitHub Desktop.

Revisions

  1. phrawzty revised this gist Apr 16, 2020. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions 3serv.py
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    #!/usr/bin/env python3

    import http.server as SimpleHTTPServer
    import socketserver as SocketServer
    import logging
  2. phrawzty revised this gist Apr 16, 2020. No changes.
  3. phrawzty revised this gist Mar 27, 2020. 2 changed files with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 2serv.py
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    #!/usr/bin/env python
    #!/usr/bin/env python2

    import SimpleHTTPServer
    import SocketServer
    File renamed without changes.
  4. phrawzty revised this gist Mar 27, 2020. 2 changed files with 20 additions and 0 deletions.
    File renamed without changes.
    20 changes: 20 additions & 0 deletions 3serv.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    #!/usr/bin/env python3
    import http.server as SimpleHTTPServer
    import socketserver as SocketServer
    import logging

    PORT = 8000

    class GetHandler(
    SimpleHTTPServer.SimpleHTTPRequestHandler
    ):

    def do_GET(self):
    logging.error(self.headers)
    SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)


    Handler = GetHandler
    httpd = SocketServer.TCPServer(("", PORT), Handler)

    httpd.serve_forever()
  5. phrawzty revised this gist Mar 5, 2015. 1 changed file with 12 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions cli.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    ```
    $ curl -s -H "X-Something: yeah" localhost:8000 > /dev/null
    ```
    ```
    $ python serv.py
    ERROR:root:User-Agent: curl/7.37.1
    Host: localhost:8000
    Accept: */*
    X-Something: yeah
    127.0.0.1 - - [05/Mar/2015 11:28:33] "GET / HTTP/1.1" 200 -
    ```
  6. phrawzty created this gist Mar 5, 2015.
    19 changes: 19 additions & 0 deletions serv.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    #!/usr/bin/env python

    import SimpleHTTPServer
    import SocketServer
    import logging

    PORT = 8000

    class GetHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):

    def do_GET(self):
    logging.error(self.headers)
    SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)


    Handler = GetHandler
    httpd = SocketServer.TCPServer(("", PORT), Handler)

    httpd.serve_forever()