Created
November 19, 2014 14:55
-
-
Save atodorov/666035d270d97d982cd5 to your computer and use it in GitHub Desktop.
Proxy servers in Python and Go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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