def throw_cup(user_id, auth_header): throw_url = '{}{}'.format( API['URL'], API['THROWS_ROUTE'], ) throw_data = {'user': user_id} requests.post(throw_url, data=throw_data, headers=auth_header)
def take_cup(user_id, auth_header): take_url = '{}{}'.format( API['URL'], API['TAKES_ROUTE'], ) take_data = {'user': user_id} requests.post(take_url, data=take_data, headers=auth_header)
def check_position(user_id, arduino_id, auth_header): url_position = '{}{}'.format( API['URL'], API['CHECKS_ROUTE'], ) position_data = {'user': user_id, 'point': arduino_id} requests.post(url_position, data=position_data, headers=auth_header)
def get_token(): login_data = { 'username': LOGIN, 'password': PASSWD, } login_url = '{}{}'.format(API['URL'], API['LOGIN_ROUTE']) r = requests.post(login_url, data=login_data) response = loads(r.content) token = response['token'] return token
def create_cp_xfer_deposit(api_base_url, api_id, api_access_token, batch_details, church_name): headers = {'Authorization': 'Bearer: {}'.format(api_access_token)} print('Posting URL: {}transactions'.format(api_base_url)) print('With headers: {}'.format(headers)) line_num = 0 payload = { "note": "Church Planting Deposit to CP Fund (Automated)", "date": batch_details["date"], "contact": { "companyname": church_name, "type": "company" }, "lines": [] } for k, v in batch_details["details"].items(): xfer_amount = v["amount"] / 10 xfer_amount = round(xfer_amount, 2) #only transfer money for that received in general fund - note that funds are different for the deposit side if v["id"] == 48655: payload["lines"].append({ "amount": xfer_amount, "account": { "account_number": 1000 }, "fund": { "id": 50194 } }) payload["lines"].append({ "amount": 0 - xfer_amount, "account": { "account_number": 4251 }, "fund": { "id": 50194 } }) jsonData = json.dumps(payload) r = requests.post('{}transactions'.format(api_base_url), headers=headers, data=jsonData) api_error_handling(r.status_code) response = r.json() sns.publish(TopicArn=sns_topic, Message=('JSON response: {}'.format(response)))
def hehe(name): resp = rq.post("http://127.0.0.1:5000/account/shit",json={ "name":name, "password":"******", "avator":"jsjsjsjsj", "profile":{ "age":1, "sex":"F", "interests":{ "1":choice([1,0,1,0]), "2":choice([1,0,1,0]), "3":"1", "4":"1", "5":choice([1,0,1,0]), } } })
def hehe(name): resp = rq.post("http://127.0.0.1:5000/account/shit", json={ "name": name, "password": "******", "avator": "jsjsjsjsj", "profile": { "age": 1, "sex": "F", "interests": { "1": choice([1, 0, 1, 0]), "2": choice([1, 0, 1, 0]), "3": "1", "4": "1", "5": choice([1, 0, 1, 0]), } } })
def upload(self, screenshot, name): path = self.save(screenshot, name) if not path: ScreenCloud.setError('Failed to save screenshot') return False with open(path, 'rb') as file: files = { 'c': ('c', file, 'image/' + ScreenCloud.getScreenshotFormat()) } try: res = requests.post(self.remote_url, files=files) res.raise_for_status() if self.copy_link: ScreenCloud.setUrl(res.text) except requests.exceptions.HTTPError as e: ScreenCloud.setError('\n' + str(e)) return False return True
#!/usr/bin/env python # encoding: utf-8 from requests import requests as rq resp = rq.post("http://127.0.0.1:5000", json={"username": "******", "password": "******"}) print resp.text
#!/usr/bin/env python # encoding: utf-8 from requests import requests as rq res = rq.post("http://127.0.0.1:5000/login", json={ "username": "******", "password": "******" }) print res.text
def test_login(): resp = rq.post("http://127.0.0.1:5000",)
def post(self, resource, data=None, **kw): if data: kw = add_json_headers(kw) data = json.dumps(data) return requests.post(self.url(resource), data, auth=(self._username, self._password), verify=self._verify, **kw)
#!/usr/bin/env python # encoding: utf-8 from requests import requests as rq res = rq.post("http://127.0.0.1:5000/login",json={"username":"******","password":"******"}) print res.text
def test_login(): resp = rq.post("http://127.0.0.1:5000", )
#!/usr/bin/env python # encoding: utf-8 from requests import requests as rq resp = rq.post("http://127.0.0.1:5000", json={ "username": "******", "password": "******" }) print resp.text