def get(**kwargs): """Summary Args: **kwargs: Description Returns: TYPE: Description """ user = kwargs.get('user') _id = kwargs.get('_id') path = BASE_PATH.format(user.json['_id']) if _id: path += '/{0}'.format(_id) response = APIClient.get(client=user.client, oauth_key=user.oauth_key, fingerprint=user.fingerprint, path=path, ip_address=user.ip_address) return Node(json=response, user=user) else: query_params = { 'type': kwargs.get('type'), 'page': kwargs.get('page', 1), 'per_page': kwargs.get('per_page', 20) } response = APIClient.get(client=user.client, oauth_key=user.oauth_key, fingerprint=user.fingerprint, path=path, query_params=query_params, ip_address=user.ip_address) return response
def get(**kwargs): """Summary Args: **kwargs: Description Returns: TYPE: Description """ _id = kwargs.get('_id') client = kwargs.get('client') fingerprint = kwargs.get('fingerprint') ip_address = kwargs.get('ip_address') if _id: path = BASE_PATH + '/' + _id response = APIClient.get(client=client, path=path, fingerprint=fingerprint, ip_address=ip_address) return User(client=client, json=response, fingerprint=fingerprint, ip_address=ip_address) else: query_params = { 'page': kwargs.get('page', 1), 'per_page': kwargs.get('per_page', 20), 'query': kwargs.get('query') } response = APIClient.get(client=client, path=BASE_PATH, fingerprint='', ip_address='', query_params=query_params) return response
def get(**kwargs): """Summary Args: **kwargs: Description Returns: TYPE: Description """ _id = kwargs.get('_id') node = kwargs.get('node') path = BASE_PATH.format(node.user.json['_id'], node.json['_id']) if _id: path += '/{0}'.format(_id) response = APIClient.get(client=node.user.client, oauth_key=node.user.oauth_key, fingerprint=node.user.fingerprint, path=path, ip_address=node.user.ip_address) return Transaction(json=response, node=node) else: query_params = { 'type': kwargs.get('type'), 'page': kwargs.get('page', 1), 'per_page': kwargs.get('per_page', 20) } response = APIClient.get(client=node.user.client, oauth_key=node.user.oauth_key, fingerprint=node.user.fingerprint, path=path, ip_address=node.user.ip_address, query_params=query_params) return response
def forward_json(myCharge): """ [email protected]:ark930/charge-forward.git :param myCharge: :return: """ url = "http://114.215.237.77:3000/forward" APIClient._http_call(url, "POST", "json", "json", None, {}, 30, **myCharge)
def delete(self): """Removes the syanpse node from the user. Returns: bool: Whether the node was successfully deleted or not. """ APIClient.delete(client=self.user.client, oauth_key=self.user.oauth_key, fingerprint=self.user.fingerprint, url=self.json['_links']['self']['href'], ip_address=self.user.ip_address) del self return True
def send(is_private,charge_id, content): if is_private==False: env_name, root_url, live_key, app_id = datagen.get_current_env() else: env_name, root_url, live_key, app_id = datagen.get_my_env() url = "{0}/notify/charges/{1}".format(root_url, charge_id) if isinstance(content, basestring): data = {} data['value'] = content response = APIClient._http_call(url, 'POST', 'text', 'form-urlencoded', None, {}, 30, **data) else: response = APIClient._http_call(url, 'POST', 'text', 'json', None, {}, 30, **content) return response
def delete(self): """Removes the syanpse node from the user. Returns: bool: Whether the node was successfully deleted or not. """ APIClient.delete( client=self.user.client, oauth_key=self.user.oauth_key, fingerprint=self.user.fingerprint, url=self.json['_links']['self']['href'], ip_address=self.user.ip_address ) del self return True
def base(is_private,channel, needforward=True, **extra): if is_private == False: env_name, root_url, live_key, app_id = datagen.get_current_env() else: env_name, root_url, live_key, app_id = datagen.get_my_env() url = "{0}/v1/charges".format(root_url) # request body charge = Model.ChargeBase.ChargeDict() charge['order_no'] = random_str(10) charge['subject'] = "Autopay_TestOrder4{0}".format(channel) charge['body'] = "appletesting4Pay" charge['amount'] = 10 charge['channel'] = channel charge['currency'] = "cny" charge['client_ip'] = "127.0.0.1" id = [("id", app_id)] charge['app'] = dict(id) charge['extra'] = extra myCharge = APIClient._http_call(url, "POST", "json", "json", None, {"Authorization": "Bearer {0}".format(live_key)}, 30, **charge) print(myCharge) if (needforward): time.sleep(5) Forward.forward_json(myCharge) else: return myCharge
def jdpay_wap(): env_name, root_url, live_key, app_id = datagen.get_current_env() url = "{0}/v1/charges".format(root_url) # request body charge = Model.ChargeBase.ChargeDict charge['order_no'] = random_str(10) charge['subject'] = 'TestOrder4jdpay_wap' charge['body'] = 'appletest4Pay' charge['amount'] = 10 charge['channel'] = 'jdpay_wap' charge['currency'] = 'cny' charge['client_ip'] = '127.0.0.1' id = [('id', app_id)] extra = [("success_url", "http://pingxx.com"), ("fail_url", "htpps://pingxx.com")] charge['app'] = dict(id) charge['extra'] = dict(extra) mycharge = APIClient._http_call(url, "post", "json", "json", None, {"Authorization": "Bearer {0}".format(live_key)}, 30, **charge) print(mycharge) sshCmd.ssh_cmd("114.215.237.77", "56f27c2B", "echo "">/var/www/example/ziteng") threading._start_new_thread(sshCmd.ssh_cmd("114.215.237.77", "56f27c2B", "echo "">/var/www/example/ziteng")) time.sleep(5) Forward.forward_json(mycharge) ret = sshCmd.ssh_cmd("114.215.237.77", "56f27c2B", "echo "">/var/www/example/ziteng") print ret if int(filter(lambda x: x.isdigit(), ret)) > 1: print "The charge file had updated on %s" % ctime() else: print "forward the charge to update file again..." threading._start_new_thread(sshCmd.ssh_cmd("114.215.237.77", "56f27c2B", "echo "">/var/www/example/ziteng")) time.sleep(2) Forward.forward_json(mycharge)
def GetChargeList100_Refund_ByChannel(channel, mode): if mode == 0: env_name, root_url, live_key, app_id = datagen.get_my_env() else: env_name, root_url, live_key, app_id = datagen.get_test_env() url = "{0}/v1/charges/".format(root_url) params = {} params["channel"] = channel params["limit"] = 100 params["paid"] = True if channel == "alipay": params["refunded"] = True else: params["refunded"] = False params["app[id]"] = app_id response = APIClient._http_call( url, 1, "json", None, {}, {"Authorization": "Bearer {0}".format(live_key)}, 30, **params ) if response["data"] is None or len(response["data"]) == 0: logging.info("GetCharge_NoRefund_ByChannel: " + channel + " No charge returned") print "GetCharge_NoRefund_ByChannel: " + channel + " No charge returned" return charge = response["data"] return charge
def create(**kwargs): """Summary Args: **kwargs: Description Returns: TYPE: Description """ user = kwargs.get('user') path = BASE_PATH.format(user.json['_id']) response = APIClient.post( client=user.client, oauth_key=user.oauth_key, fingerprint=user.fingerprint, path=path, payload=kwargs.get('payload'), ip_address=user.ip_address ) if 'mfa' in response: return response else: nodes = [] for node in response['nodes']: nodes.append(Node(json=node, user=user)) return nodes
def GetCharge(chargeid): env_name, root_url, test_key,app_id = datagen.get_my_test_env() url = "{0}/v1/charges/{1}".format(root_url,chargeid) params ={} response = APIClient._http_call(url, 1, 'json', None, {}, {"Authorization": "Bearer {0}".format(test_key)}, 30, **params) print response
def forward_alipay(myCharge): # JUST FORWARD THE CHARGE INFO TO DEMO APP FOR PAY # NO NEED SOCKET HERE # try: # s = socket.socket(socket.AF_INET,socket.SOCK_STREAM) # remoteIP = "114.215.237.77" # port = 8880 # s.connect((remoteIP, port)) # except socket.error: # sys.exit() # # print('Socket Created') url = "http://114.215.237.77:3000/forward" APIClient._http_call(url, "POST", "json", "json", None, {}, 30, id=myCharge['id'].encode('utf-8') , object=myCharge['object'].encode('utf-8') , created=myCharge['created'] , livemode=myCharge['livemode'] , paid=myCharge['paid'] , refunded=myCharge['refunded'] , app=myCharge['app'].encode('utf-8') , channel=myCharge['channel'].encode('utf-8') , order_no=myCharge['order_no'].encode('utf-8') , client_ip=myCharge['client_ip'].encode('utf-8') , amount=myCharge['amount'] , amount_settle=myCharge['amount_settle'] , currency=myCharge['currency'].encode('utf-8') , subject=myCharge['subject'].encode('utf-8') , body=myCharge['body'].encode('utf-8') , extra=myCharge['extra'] , time_paid=myCharge['time_paid'] , time_expire=myCharge['time_expire'] , time_settle=myCharge['time_settle'] , transaction_no=myCharge['transaction_no'] , refunds={"object": myCharge['refunds']['object'].encode('utf-8'), "url": myCharge['refunds']['url'].encode('utf-8'), "has_more":myCharge['refunds']['has_more'], "data":[]} , credential={"object": myCharge['credential']['object'].encode('utf-8'), "alipay": myCharge['credential']['alipay']} , amount_refunded=myCharge['amount_refunded'] , failure_code=myCharge['failure_code'] , failure_msg=myCharge['failure_msg'] , metadata=myCharge['metadata'] , description=myCharge['description'] )
def GetCharge(is_private,chargeid): if is_private==False: env_name, root_url, live_key,app_id = datagen.get_current_env() else: env_name, root_url, live_key,app_id = datagen.get_my_env() url = "{0}/v1/charges/{1}".format(root_url,chargeid) params ={} response = APIClient._http_call(url, 1, 'json', None, {}, {"Authorization": "Bearer {0}".format(live_key)}, 30, **params) print response
def bfb(): env_name, root_url, test_key, app_id = datagen.get_my_test_env() url = "{0}/v1/charges".format(root_url) # request body charge = Model.ChargeBase.Charge() charge.order_no = random_str(10) charge.channel = "bfb" myCharge = APIClient._http_call(url, "POST", "json", "json", None, {"Authorization": "Bearer {0}".format(test_key)}, 30, subject=charge.subject, body=charge.body, app={"id": charge.app.id}, amount=charge.amount, channel=charge.channel, client_ip=charge.client_ip, currency=charge.currency, order_no=charge.order_no) return myCharge["id"]
def delete(self): """Cancels the transaction Returns: bool: True if transaction successfully canceled or False otherwise """ response = APIClient.delete(client=self.node.user.client, oauth_key=self.node.user.oauth_key, fingerprint=self.node.user.fingerprint, url=self.json['_links']['self']['href'], ip_address=self.node.user.ip_address) del self return response['recent_status']['status'] == u'CANCELED'
def base(channel): env_name, root_url, live_key, app_id = datagen.get_current_env() url = "{0}/v1/charges/".format(root_url) params = {} params["channel"] = channel params["limit"] = 1 params["paid"] = False params["app[id]"] = app_id response = APIClient._http_call( url, 1, "json", None, {}, {"Authorization": "Bearer {0}".format(live_key)}, 30, **params ) charge = response["data"][0] return charge
def get(**kwargs): """Summary Args: **kwargs: Description Returns: TYPE: Description """ _id = kwargs.get('_id') node = kwargs.get('node') path = BASE_PATH.format(node.user.json['_id'], node.json['_id']) if _id: path += '/{0}'.format(_id) response = APIClient.get( client=node.user.client, oauth_key=node.user.oauth_key, fingerprint=node.user.fingerprint, path=path, ip_address=node.user.ip_address ) return Transaction(json=response, node=node) else: query_params = { 'type': kwargs.get('type'), 'page': kwargs.get('page', 1), 'per_page': kwargs.get('per_page', 20) } response = APIClient.get( client=node.user.client, oauth_key=node.user.oauth_key, fingerprint=node.user.fingerprint, path=path, ip_address=node.user.ip_address, query_params=query_params ) return response
def get(**kwargs): """Summary Args: **kwargs: Description Returns: TYPE: Description """ user = kwargs.get('user') _id = kwargs.get('_id') path = BASE_PATH.format(user.json['_id']) if _id: path += '/{0}'.format(_id) response = APIClient.get( client=user.client, oauth_key=user.oauth_key, fingerprint=user.fingerprint, path=path, ip_address=user.ip_address ) return Node(json=response, user=user) else: query_params = { 'type': kwargs.get('type'), 'page': kwargs.get('page', 1), 'per_page': kwargs.get('per_page', 20) } response = APIClient.get( client=user.client, oauth_key=user.oauth_key, fingerprint=user.fingerprint, path=path, query_params=query_params, ip_address=user.ip_address ) return response
def delete(self): """Cancels the transaction Returns: bool: True if transaction successfully canceled or False otherwise """ response = APIClient.delete( client=self.node.user.client, oauth_key=self.node.user.oauth_key, fingerprint=self.node.user.fingerprint, url=self.json['_links']['self']['href'], ip_address=self.node.user.ip_address ) del self return response['recent_status']['status'] == u'CANCELED'
def create(**kwargs): """Summary Args: **kwargs: Description Returns: TYPE: Description """ node = kwargs.get('node') path = BASE_PATH.format(node.user.json['_id'], node.json['_id']) response = APIClient.post(client=node.user.client, oauth_key=node.user.oauth_key, fingerprint=node.user.fingerprint, path=path, payload=kwargs.get('payload')) return Transaction(json=response, node=node)
def update(self, **kwargs): """Used to verify a micro-deposit Node. Args: **kwargs: payload - the json object to be sent to the server Returns: Node: self """ response = APIClient.patch(client=self.user.client, oauth_key=self.user.oauth_key, fingerprint=self.user.fingerprint, payload=kwargs.get('payload'), url=self.json['_links']['self']['href'], ip_address=self.user.ip_address) self.json = response return response
def update(self, **kwargs): """Updates the transaction with a given comment. Args: **kwargs: payload - json object to PATCH the transaction with Returns: Transaction: The updated transaction """ response = APIClient.patch(client=self.node.user.client, oauth_key=self.node.user.oauth_key, fingerprint=self.node.user.fingerprint, payload=kwargs.get('payload'), url=self.json['_links']['self']['href'], ip_address=self.node.user.ip_address) self.json = response['trans'] return response
def bfb(): env_name, root_url, live_key, app_id = datagen.get_current_env() url = "{0}/v1/charges".format(root_url) # request body charge = Model.ChargeBase.Charge() charge.order_no = random_str(10) charge.channel = "bfb" myCharge = APIClient._http_call(url, "POST", "json", "json", None, {"Authorization": "Bearer {0}".format(live_key)}, 30, subject=charge.subject, body=charge.body, app={"id": charge.app.id}, amount=charge.amount, channel=charge.channel, client_ip=charge.client_ip, currency=charge.currency, order_no=charge.order_no) # Get the charge info(json) and send to another API for forward #And the demo app will receive the charge Info for pay #print(myCharge) Forward.forward_json(myCharge)
def get_oauth_key(self): """Summary Returns: TYPE: Description """ payload = { 'refresh_token': self.json['refresh_token'] } path = 'api/3/oauth/{0}'.format(self.json['_id']) response = APIClient.post( client=self.client, fingerprint=self.fingerprint, path=path, payload=payload, ip_address=self.ip_address ) return response['oauth_key']
def create(**kwargs): """Summary Args: **kwargs: Description Returns: TYPE: Description """ node = kwargs.get('node') path = BASE_PATH.format(node.user.json['_id'], node.json['_id']) response = APIClient.post( client=node.user.client, oauth_key=node.user.oauth_key, fingerprint=node.user.fingerprint, path=path, payload=kwargs.get('payload') ) return Transaction(json=response, node=node)
def GetTransfer_received(mode): if mode == 0: env_name, root_url, live_key, app_id = datagen.get_current_env() else: env_name, root_url, live_key, app_id = datagen.get_test_env() url = "{0}/v1/transfers/".format(root_url) params = {} params["limit"] = 1 params["app[id]"] = app_id response = APIClient._http_call( url, 1, "json", None, {}, {"Authorization": "Bearer {0}".format(live_key)}, 30, **params ) if response["data"] == None or len(response["data"]) == 0: logging.info("GetOrder_NoRefund_ByChannel: " + " No charge returned") print "GetCharge_NoRefund_ByChannel: " + " No charge returned" return transfer = response["data"][0] return transfer["id"]
def update(self, **kwargs): """Used to verify a micro-deposit Node. Args: **kwargs: payload - the json object to be sent to the server Returns: Node: self """ response = APIClient.patch( client=self.user.client, oauth_key=self.user.oauth_key, fingerprint=self.user.fingerprint, payload=kwargs.get('payload'), url=self.json['_links']['self']['href'], ip_address=self.user.ip_address ) self.json = response return response
def answer_kba(self, **kwargs): """Summary Args: **kwargs: Description Returns: TYPE: Description """ response = APIClient.patch( client=self.client, oauth_key=self.oauth_key, url=self.json['_links']['self']['href'], fingerprint=self.fingerprint, payload=kwargs.get('payload'), ip_address=self.ip_address ) self.json = response return response
def update(self, **kwargs): """Updates the transaction with a given comment. Args: **kwargs: payload - json object to PATCH the transaction with Returns: Transaction: The updated transaction """ response = APIClient.patch( client=self.node.user.client, oauth_key=self.node.user.oauth_key, fingerprint=self.node.user.fingerprint, payload=kwargs.get('payload'), url=self.json['_links']['self']['href'], ip_address=self.node.user.ip_address ) self.json = response['trans'] return response
def add_doc(self, **kwargs): """Summary Args: **kwargs: Description Returns: TYPE: Description """ response = APIClient.patch( client=self.client, url=self.json['_links']['self']['href'], oauth_key=self.oauth_key, fingerprint=self.fingerprint, payload=kwargs.get('payload'), ip_address=self.ip_address ) if response.get('http_code','200') != '202': self.json = response return response
def yeepay_wap(): env_name, root_url, live_key, app_id = datagen.get_current_env() url = "{0}/v1/charges".format(root_url) # request body charge = Model.ChargeBase.ChargeDict() charge['order_no'] = random_str(10) charge['subject'] = "TestOrder4YeepayWap" charge['body'] = "appletesting4Pay" charge['amount'] = 10 charge['channel'] = "yeepay_wap" charge['currency'] = "cny" charge['client_ip'] = "127.0.0.1" id = [("id", app_id)] extra = [("product_category", "1"), ("identity_id", "d2:bf:11:78:09:69"), ("identity_type", "0"), ("terminal_type", "1"), ("terminal_id", "d2:bf:11:78:09:69"), ("user_ua", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:36.0) Gecko/20100101 Firefox/36.0"), ("result_url", "https://pingxx.com")] charge['extra'] = dict(extra) charge['app'] = dict(id) myCharge = APIClient._http_call(url, "post", "json", "json", None, {"Authorization": "Bearer {0}".format(live_key)}, 30, **charge) print(myCharge) sshCmd.ssh_cmd("114.215.237.77", "56f27c2B", "echo "">/var/www/example/ziteng.php") threading._start_new_thread(sshCmd.ssh_cmd, ("114.215.237.77", "56f27c2B", "php /var/www/example/client4ziteng.php")) time.sleep(5) Forward.forward_json(myCharge) ret = sshCmd.ssh_cmd("114.215.237.77", "56f27c2B", "echo $(stat -c %s /var/www/example/ziteng.php)") print ret if int(filter(lambda x: x.isdigit(), ret)) > 1: print "The charge file had updated on %s" % ctime() else: print "forward the charge to update the file again..." threading._start_new_thread(sshCmd.ssh_cmd, ("114.215.237.77", "56f27c2B", "php /var/www/example/client4ziteng.php")) time.sleep(2) Forward.forward_json(myCharge)
def create(**kwargs): """Summary Args: **kwargs: Description Returns: TYPE: Description """ client = kwargs.get('client') fingerprint = kwargs.get('fingerprint') ip_address = kwargs.get('ip_address') response = APIClient.post(client=client, fingerprint=fingerprint, payload=kwargs.get('payload'), ip_address=ip_address, path=BASE_PATH) return User(client=client, json=response, fingerprint=fingerprint, ip_address=ip_address)
def GetOrderList_NotRefund(mode): if mode == 0: env_name, root_url, live_key, app_id = datagen.get_my_env() else: env_name, root_url, live_key, app_id = datagen.get_test_env() url = "{0}/v1/charges/".format(root_url) params = {} params["limit"] = 2 params["paid"] = True params["refunded"] = False params["app[id]"] = app_id response = APIClient._http_call( url, 1, "json", None, {}, {"Authorization": "Bearer {0}".format(live_key)}, 30, **params ) if response["data"] == None or len(response["data"]) == 0: logging.info("GetOrder_NoRefund_ByChannel: " + " No charge returned") print "GetCharge_NoRefund_ByChannel: " + " No charge returned" return charge = response["data"] return charge[0]["order_no"], charge[1]["order_no"]
def bfb_wap(): env_name, root_url, live_key, app_id = datagen.get_current_env() url = "{0}/v1/charges".format(root_url) # request body charge = Model.ChargeBase.ChargeDict() charge['order_no'] = random_str(10) charge['subject'] = "TestOrder4bfbWap" charge['body'] = "appletesting4Pay" charge['amount'] = 10 charge['channel'] = "bfb_wap" charge['currency'] = "cny" charge['client_ip'] = "127.0.0.1" id = [("id", app_id)] extra = [("result_url", "http://pingxx.com"), ("bfb_login", "false")] charge['extra'] = dict(extra) charge['app'] = dict(id) myCharge = APIClient._http_call(url, "POST", "json", "json", None, {"Authorization": "Bearer {0}".format(live_key)}, 30, **charge) print(myCharge) sshCmd.ssh_cmd("114.215.237.77", "56f27c2B", "echo "">/var/www/example/ziteng.php") threading._start_new_thread(sshCmd.ssh_cmd, ("114.215.237.77", "56f27c2B", "php /var/www/example/client4ziteng.php")) time.sleep(5) Forward.forward_json(myCharge) ret = sshCmd.ssh_cmd("114.215.237.77", "56f27c2B", "echo $(stat -c %s /var/www/example/ziteng.php)") print ret if int(filter(lambda x: x.isdigit(), ret)) > 1: print "The charge file had updated on %s" % ctime() else: print "forward the charge to update the file again..." threading._start_new_thread(sshCmd.ssh_cmd, ("114.215.237.77", "56f27c2B", "php /var/www/example/client4ziteng.php")) time.sleep(2) Forward.forward_json(myCharge)
def alipay(): """ 1- Generate the charge via API 2- Forward the charge so that the demoapp will reflush """ env_name, root_url, live_key, app_id = datagen.get_current_env() url = "{0}/v1/charges".format(root_url) # request body charge = Model.ChargeBase.Charge() charge.order_no = random_str(10) # myCharge = APIClient._http_call(url,"POST","json","json",None,{"Authorization":"Bearer sk_live_vjfr90jj1q985KuPO84iP8KO"},30,charge.__dict__) myCharge = APIClient._http_call(url, "POST", "json", "json", None, {"Authorization": "Bearer {0}".format(live_key)}, 30, subject=charge.subject, body=charge.body, app={"id": charge.app.id}, amount=charge.amount, channel=charge.channel, client_ip=charge.client_ip, currency=charge.currency, order_no=charge.order_no) #Get the charge info(json) and send to another API for forward #And the demo app will receive the charge Info for pay print(myCharge) Forward.forward_alipay(myCharge)
def create(**kwargs): """Summary Args: **kwargs: Description Returns: TYPE: Description """ user = kwargs.get('user') path = BASE_PATH.format(user.json['_id']) response = APIClient.post(client=user.client, oauth_key=user.oauth_key, fingerprint=user.fingerprint, path=path, payload=kwargs.get('payload'), ip_address=user.ip_address) if 'mfa' in response: return response else: nodes = [] for node in response['nodes']: nodes.append(Node(json=node, user=user)) return nodes
from APIClient import * """ 2019 Cruz Hacks """ client = APIClient("people_13") client.create_database("Known Users") client.add_person( "Tejas", "your grandson who doesn't need sleep", "static/tejas/*.jpg", "Tejas goes to Diablo Valley College and has been to over 40 hackathons.") client.add_person( "Andrew", "your annoying friend who goes to UCSC", "static/andrew/*.jpg", "Andrew was born in Santa Cruz but grew up in Silicon Valley. He likes building robots and reading the changelog for new Python features." ) client.add_person( "Stewart", "your grandchild who likes to hack on hardware", "static/stewart/*.jpg", "Stewart is your grandchild who lives in Los Angeles. He likes to come over to see you and help you mow your lawn." ) client.add_person( "Egypt", "your friend who helps you get groceries", "static/egypt/*.jpg", "Egypt is your friend that has good hair and user experience skills.") client.add_person( "Torin", "your grandson who lives in Marina", "static/torin/*.jpg", "Torin is your grandson who is a teaching assistant at CSUMB.") client.train_data() client.print_status() client.print_list()
cred = credentials.Certificate( 'project-anti-alz-firebase-adminsdk-zlh54-decaa0ce0a.json') # firebase_admin.initialize_app(cred, {'databaseURL' : 'https://project-anti-alz.firebaseio.com/'}) root = db.reference() # Imports the Google Cloud client library from google.cloud import storage # The name for the new bucket bucket_name = 'history-images-3519435695' # bucket = storage_client.create_bucket(bucket_name) app = Flask(__name__) CORS(app) bootstrap = Bootstrap(app) client = APIClient("people_13") epoch = lambda: int(time.time() * 1000) @app.route("/") def index(): return render_template("index.html") @app.route('/detect-face', methods=['POST']) def detect_face(): img_content = request.data filename = md5(img_content).hexdigest() img_path = "uploads/" + filename + ".jpg"