@@ -378,33 +378,26 @@ def user_information():
378
378
Handle user information requests
379
379
"""
380
380
if request .method == "GET" :
381
- # Return the user information (assuming there's only one user in this case)
382
381
return jsonify ([user .__dict__ for user in data ["user_information" ]]), 200
383
382
384
383
request_body = request .get_json ()
385
384
386
- # Validate the required fields
387
385
error = validate_fields (["name" , "email_address" , "phone_number" ], request_body )
388
386
if error :
389
387
return jsonify ({"error" : f"{ ', ' .join (error )} parameter(s) is required" }), 400
390
388
391
- # Validate the phone number format
392
389
is_valid_phone_number = validate_phone_number (request_body ["phone_number" ])
393
390
if not is_valid_phone_number :
394
391
return jsonify ({"error" : "Invalid phone number" }), 400
395
392
396
393
if request .method in ("POST" , "PUT" ):
397
- # Create new user information instance
398
394
new_user_information = UserInformation (
399
395
name = request_body ["name" ],
400
396
email_address = request_body ["email_address" ],
401
397
phone_number = request_body ["phone_number" ]
402
398
)
403
399
404
- # Since user information is unique, overwrite the existing one
405
400
data ["user_information" ] = [new_user_information ]
406
-
407
- # Save the data to the JSON file
408
401
save_data ("data/data.json" , data )
409
402
410
403
return jsonify (new_user_information .__dict__ ), 201
@@ -537,8 +530,8 @@ def uploaded_file(filename):
537
530
538
531
@app .route ("/resume/data" , methods = ["GET" ])
539
532
def get_data ():
540
- data = load_data ("data/data.json" )
541
533
"""
542
534
Get all data from the data.json file
543
535
"""
544
- return jsonify (data ), 200
536
+ final_data = load_data ("data/data.json" )
537
+ return jsonify (final_data ), 200
0 commit comments