def main (argv): wallet = Wallet() username = Config().username requests = BitTransferRequests(wallet, username) r = requests.get(url='http://10.8.235.166:5000/%s' % (argv[1] if len(argv) > 1 else '')) print(r.text)
from two1.lib.bitrequests import BitTransferRequests EXAMPLE_SERVER = "http://127.0.0.1:5000" PROXY = "http://127.0.0.1:9000" proxies = {"http": PROXY} wallet = Wallet() username = Config().username requests = BitTransferRequests(wallet, username) print("Call the example server directly") print("The goal here is to confirm that the example server is \ reachable and can distinguish between a proxied and non-proxied \ connection.") r = requests.get(url=EXAMPLE_SERVER + "/AmIBehindProxy") print(r.text) print("Call the example debug server though the proxy, paying 1000 satoshis per request") print("The goal here is to confirm that the example server was hit through a proxy.") r = requests.get(url=EXAMPLE_SERVER + "/AmIBehindProxy", proxies=proxies) print(r.text) print("Now call a real server at princeton.edu by paying the proxy some bitcoin") r = requests.get(url="https://www.princeton.edu", proxies=proxies) # print(r.text) # write output to file with open('princeton.html', 'w') as f: f.write(r.text)
from two1.commands.config import Config from two1.lib.wallet import Wallet from two1.lib.bitrequests import BitTransferRequests import sys wallet = Wallet() username = Config().username requests = BitTransferRequests(wallet, username) keys = ['a', 'b', 'up', 'down', 'left', 'right', 'start', 'select'] if __name__ == '__main__': if len(sys.argv) < 2: print('Usage: python3 client.py <server>') server_url = 'http://{}'.format(sys.argv[1]) while(True): key = input('Button ({})? '.format('/'.join(keys))) if key not in keys: print('Invalid button') else: req_url = '{}/press/{}'.format(server_url, key) answer = requests.get(url=req_url) if answer.status_code != 200: print("Could not make payment.")