server/client recom.. connection 👍
This commit is contained in:
@@ -1,4 +0,0 @@
|
|||||||
import subprocess
|
|
||||||
|
|
||||||
if (subprocess.run("mysql -u root mysql < mysql-code/Schema.sql", shell=True, check=True)):
|
|
||||||
print("successfully created the Marketplace databse")
|
|
||||||
BIN
recommondation-engine/__pycache__/example1.cpython-313.pyc
Normal file
BIN
recommondation-engine/__pycache__/example1.cpython-313.pyc
Normal file
Binary file not shown.
@@ -1,7 +1,6 @@
|
|||||||
# pip install mysql.connector
|
# pip install mysql.connector
|
||||||
|
|
||||||
import mysql.connector
|
import mysql.connector
|
||||||
from sklearn.feature_extraction.text import TfidfVectorizer
|
|
||||||
from sklearn.metrics.pairwise import cosine_similarity
|
from sklearn.metrics.pairwise import cosine_similarity
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import logging
|
import logging
|
||||||
@@ -108,6 +107,3 @@ def get_recommendations(user_id, top_n=40):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Recommendation error for user {user_id}: {str(e)}")
|
logging.error(f"Recommendation error for user {user_id}: {str(e)}")
|
||||||
# return get_popular_products(top_n) # Fallback to popular products
|
# return get_popular_products(top_n) # Fallback to popular products
|
||||||
|
|
||||||
|
|
||||||
get_recommendations(1)
|
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
from flask import Flask, request, jsonify
|
from flask import Flask, request, jsonify
|
||||||
from flask_cors import CORS
|
from flask_cors import CORS
|
||||||
|
from example1 import get_recommendations
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
CORS(app) # Enable CORS for all routes
|
CORS(app) # Enable CORS for all routes
|
||||||
@@ -15,6 +18,9 @@ def handle_session_data():
|
|||||||
if not user_id or not email or is_authenticated is None:
|
if not user_id or not email or is_authenticated is None:
|
||||||
return jsonify({'error': 'Invalid data'}), 400
|
return jsonify({'error': 'Invalid data'}), 400
|
||||||
|
|
||||||
|
print(get_recommendations(user_id))
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
print(f"Received session data: User ID: {user_id}, Email: {email}, Authenticated: {is_authenticated}")
|
print(f"Received session data: User ID: {user_id}, Email: {email}, Authenticated: {is_authenticated}")
|
||||||
return jsonify({'message': 'Session data received successfully'})
|
return jsonify({'message': 'Session data received successfully'})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user