package main
import (
"fmt"
"net/http"
)
func main() {
client := &http.Client{
Transport: &http.Transport{},
CheckRedirect: func(req *http.Request, via []*http.Request) error {
if len(via) > 0 {
fmt.Printf("%s -> %s\n", via[len(via)-1].URL.String(), req.URL.String())
}
return nil
},
}
res, err := client.Get("...")
}
import asyncio
q_transmit = asyncio.Queue()
q_receive = asyncio.Queue()
@asyncio.coroutine
def check_queue(ws):
while True:
output_msg = yield from q_transmit.get()
ws.send_str(output_msg)
@asyncio.coroutine
def websocket_handler(request):
ws = web.WebSocketResponse()
ws.start(request)
loop.call_soon(asyncio.async, check_queue(ws))
while True:
msg = yield from ws.receive()
return ws