Skip to content

Commit

Permalink
Vuelto a añadir el endpoint en los api-*.py de datadb
Browse files Browse the repository at this point in the history
Vuelto a añadir el endpoint en los api-*.py de datadb

Vuelto a añadir el endpoint en los api-*.py de datadb

Vuelto a añadir el endpoint en los api-*.py de datadb

Vuelto a añadir el endpoint en los api-*.py de datadb
  • Loading branch information
VicDominguez committed Jun 21, 2023
1 parent b999267 commit 20784dd
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/api-prod.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import json

from flask import Flask, request

from src.endpoints import Endpoints
Expand Down Expand Up @@ -39,6 +41,15 @@ def one_off_questionnaires():
return endpoints.one_off_questionnaires_endpoint(request_data)


@app.route('/bg_data', methods=["POST"])
def user_databg():
"""Save user background data from the app"""
request_databg0 = request.json
request_databg = json.loads(request_databg0)
logger.info(f'A request has been received with the following data: {request_databg}')
return endpoints.user_databg_endpoint(request_databg)


# If this script is being executed and not imported, deploy the API
if __name__ == '__main__':
app.run(host="0.0.0.0")
20 changes: 20 additions & 0 deletions src/api-test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import json

from flask import Flask, request

from src.endpoints import Endpoints
Expand Down Expand Up @@ -38,6 +40,24 @@ def one_off_questionnaires():
logger.info(f'A request has been received with the following data: {request_data}')
return endpoints.one_off_questionnaires_endpoint(request_data)

@app.route('/bg_data', methods=["POST"])
def user_databg():
"""Save user background data from the app"""
request_databg0 = request.json
request_databg = json.loads(request_databg0)
logger.info(f'A request has been received with the following data: {request_databg}')
return endpoints.user_databg_endpoint(request_databg)



@app.route('/bg_data', methods=["POST"])
def user_databg():
"""Save user background data from the app"""
request_databg0 = request.json
request_databg = json.loads(request_databg0)
logger.info(f'A request has been received with the following data: {request_databg}')
return endpoints.user_databg_endpoint(request_databg)


# If this script is being executed and not imported, deploy the API
if __name__ == '__main__':
Expand Down
1 change: 1 addition & 0 deletions tests/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def testInsertOneOffQuestionnaires(self):
response = self.database.insert_one_off_questionnaires(data)
self.assertTrue(response.acknowledged, "ACK must be positive")
self.assertIsNotNone(response.inserted_ids, "Id must be not none")

def testInsertUserDataBg(self):
path = Path(__file__).parent / '../json/input' / 'user_data_full_data.json'
with path.open() as json_file:
Expand Down

0 comments on commit 20784dd

Please sign in to comment.