Skip to content

Instantly share code, notes, and snippets.

@atodorov
Created November 19, 2014 14:55
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 atodorov/666035d270d97d982cd5 to your computer and use it in GitHub Desktop.
Save atodorov/666035d270d97d982cd5 to your computer and use it in GitHub Desktop.
Proxy servers in Python and Go
package main
import (
"github.com/elazarl/goproxy"
"log"
"net/http"
"runtime"
)
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
proxy := goproxy.NewProxyHttpServer()
proxy.Verbose = false
log.Fatal(http.ListenAndServe(":9090", proxy))
}
#!/usr/bin/env python
import twisted.internet
from twisted.web import http
from twisted.web import proxy
class HTTPNoLoggingFactory(http.HTTPFactory):
protocol = proxy.Proxy
def log(self, request):
pass
if __name__ == '__main__':
c = twisted.internet.reactor.listenTCP(8080, HTTPNoLoggingFactory())
twisted.internet.reactor.run()
package main
import (
"log"
"net/http"
"runtime"
)
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
server := http.FileServer(http.Dir("/tmp/"))
log.Print(http.ListenAndServe(":8000", server))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment