ProfileDone
Some checks failed
K8S Fission Deployment / Deployment fission functions (push) Failing after 21s
Some checks failed
K8S Fission Deployment / Deployment fission functions (push) Failing after 21s
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import crud
|
||||
from flask import jsonify, request
|
||||
from helpers import init_db_connection, CORS_HEADERS
|
||||
|
||||
from helpers import CORS_HEADERS
|
||||
|
||||
|
||||
def main():
|
||||
@@ -33,15 +32,16 @@ def main():
|
||||
|
||||
def make_insert_request():
|
||||
try:
|
||||
user_id = request.headers.get("X-UserId")
|
||||
user_id = request.headers.get("X-User")
|
||||
if not user_id:
|
||||
return jsonify({"errorCode": "USER_ID_REQUIRED"}), 400, CORS_HEADERS
|
||||
|
||||
# Lấy dữ liệu từ body của request (thông tin hồ sơ người dùng)
|
||||
data = request.get_json()
|
||||
|
||||
response, status = crud.insert_profile(data)
|
||||
|
||||
return jsonify(response), status
|
||||
|
||||
response, status, header = crud.insert_profile(user_id, data)
|
||||
|
||||
return jsonify(response), status, header
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
@@ -49,15 +49,15 @@ def make_insert_request():
|
||||
def make_update_request():
|
||||
try:
|
||||
data = request.get_json() # Lay du lieu json tu request body
|
||||
|
||||
user_id = data.get("user_id")
|
||||
|
||||
user_id = request.headers.get("X-User")
|
||||
if not user_id:
|
||||
return jsonify({"error": "user_id is required"}), 400
|
||||
|
||||
|
||||
# Call CRUD function to update profile
|
||||
response, status = crud.update_profile
|
||||
return jsonify(response), status
|
||||
|
||||
response, status, header = crud.update_profile(user_id, data)
|
||||
return jsonify(response), status, header
|
||||
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
@@ -67,9 +67,9 @@ def make_get_request():
|
||||
user_id = request.headers.get("X-User")
|
||||
if not user_id:
|
||||
return jsonify({"error": "user_id is required"}), 400
|
||||
|
||||
response, status = crud.get_profile(user_id)
|
||||
return jsonify(response), status
|
||||
|
||||
|
||||
response, status, header = crud.get_profile(user_id)
|
||||
return jsonify(response), status, header
|
||||
|
||||
except Exception as e:
|
||||
return jsonify({"error": str(e)}), 500
|
||||
|
||||
Reference in New Issue
Block a user