Skip to content

Instantly share code, notes, and snippets.

@atodorov atodorov/proxy.go
Created Nov 19, 2014

Embed
What would you like to do?
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
You can’t perform that action at this time.