# Collection of code snippets by Arne Vajhøj 
# (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
import urllib3

http = urllib3.PoolManager()

def test(urlstr):
    # write request message and read response message
    outmsg = 'Hi from Python!\r\n'
    r = http.request('POST', urlstr, body=outmsg)
    if r.status == 200:
        inmsg = r.data.rstrip()
        print(inmsg)
    else:
        print('HTTP error : %d' % (r.status))

test('http://localhost:12345/')
test('http://localhost:12346/')
