Subbu1304 commited on
Commit
dba5d23
·
verified ·
1 Parent(s): f2ae38c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -15,23 +15,32 @@ import requests # Import requests for exception handling
15
  app = Flask(__name__)
16
 
17
 
 
 
 
 
 
 
 
 
 
18
  @app.route('/validate-login', methods=['POST'])
19
  def validate_login():
20
  login_data = request.json
21
  email = login_data.get('email')
22
  mobile = login_data.get('mobile')
23
 
24
- # Query Salesforce for the customer login record matching the email and mobile
25
  query = f"SELECT Id FROM Customer_Login__c WHERE Email__c = '{email}' AND Mobile_Number__c = '{mobile}' LIMIT 1"
26
  result = sf.query(query)
27
 
28
  if result['records']:
29
- # If a matching record is found, return success
30
  return jsonify({"valid": True})
31
  else:
32
- # If no matching record is found, return failure
33
  return jsonify({"valid": False})
34
 
 
 
 
35
  # Use whisper-small for faster processing and better speed
36
  device = "cuda" if torch.cuda.is_available() else "cpu"
37
 
 
15
  app = Flask(__name__)
16
 
17
 
18
+ from flask import Flask, request, jsonify
19
+ from flask_cors import CORS
20
+ from simple_salesforce import Salesforce
21
+
22
+ app = Flask(__name__)
23
+ CORS(app) # This enables CORS for all domains
24
+
25
+
26
+
27
  @app.route('/validate-login', methods=['POST'])
28
  def validate_login():
29
  login_data = request.json
30
  email = login_data.get('email')
31
  mobile = login_data.get('mobile')
32
 
 
33
  query = f"SELECT Id FROM Customer_Login__c WHERE Email__c = '{email}' AND Mobile_Number__c = '{mobile}' LIMIT 1"
34
  result = sf.query(query)
35
 
36
  if result['records']:
 
37
  return jsonify({"valid": True})
38
  else:
 
39
  return jsonify({"valid": False})
40
 
41
+ if __name__ == '__main__':
42
+ app.run(debug=True, host='0.0.0.0', port=5000) # Ensuring the Flask app runs on port 5000
43
+
44
  # Use whisper-small for faster processing and better speed
45
  device = "cuda" if torch.cuda.is_available() else "cpu"
46