Files
Campus-Plug/recommondation-engine/server.py

35 lines
961 B
Python
Raw Normal View History

2025-04-12 11:27:27 -06:00
2025-03-30 00:20:42 -06:00
from flask import Flask, request, jsonify
from flask_cors import CORS
2025-04-03 18:56:39 -06:00
from app import get_recommendations
2025-03-30 00:20:42 -06:00
app = Flask(__name__)
CORS(app) # Enable CORS for all routes
@app.route('/api/user/session', methods=['POST'])
def handle_session_data():
try:
data = request.get_json()
user_id = data.get('userId')
email = data.get('email')
is_authenticated = data.get('isAuthenticated')
if not user_id or not email or is_authenticated is None:
return jsonify({'error': 'Invalid data'}), 400
2025-04-03 18:56:39 -06:00
get_recommendations(user_id)
2025-04-03 12:15:32 -06:00
2025-03-30 00:20:42 -06:00
print(f"Received session data: User ID: {user_id}, Email: {email}, Authenticated: {is_authenticated}")
return jsonify({'message': 'Session data received successfully'})
except Exception as e:
print(f"Error: {e}")
return jsonify({'error': 'Server error'}), 500
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=5000)