Commit e20de30c authored by Lihinikaduwa D.N.R.  's avatar Lihinikaduwa D.N.R.

Update Read Session Status Done

parent b2d7c8d9
...@@ -4,8 +4,8 @@ import random ...@@ -4,8 +4,8 @@ import random
import os import os
from API.model.colorModel import get_color_activities1, get_color_activities2, get_color_activity_result, \ from API.model.colorModel import get_color_activities1, get_color_activities2, get_color_activity_result, \
save_color_session_details save_color_session_details
from API.model.readModel import get_reading_activities, save_activity_details, save_session_details from API.model.readModel import *
from API.model.userModel import getUser, saveUserSession, logoutUser from API.model.userModel import *
from API.model.colorModel import get_color_activities1, get_color_activities2, get_color_activity_result, storeResult from API.model.colorModel import get_color_activities1, get_color_activities2, get_color_activity_result, storeResult
from API.model.readModel import get_reading_activities from API.model.readModel import get_reading_activities
from API.routers.router import funtion_one from API.routers.router import funtion_one
...@@ -20,7 +20,8 @@ app = Flask(__name__) ...@@ -20,7 +20,8 @@ app = Flask(__name__)
def home(): def home():
return render_template('home.html') return render_template('home.html')
#=================================================================================
# =================================================================================
# Color Function Route (IT18218640) # Color Function Route (IT18218640)
# Get Color activities 1 route # Get Color activities 1 route
...@@ -28,15 +29,16 @@ def home(): ...@@ -28,15 +29,16 @@ def home():
def getColorActivities1(): def getColorActivities1():
return get_color_activities1() return get_color_activities1()
# Get Color activities 2 route # Get Color activities 2 route
@app.route("/getColorActivities2") @app.route("/getColorActivities2")
def getColorActivities2(): def getColorActivities2():
return get_color_activities2() return get_color_activities2()
# Get Color result route # Get Color result route
@app.route("/getColorActivitiesResult") @app.route("/getColorActivitiesResult")
def getColorActivitiesResult(): def getColorActivitiesResult():
req = request.get_json() req = request.get_json()
userId = req['userId'] userId = req['userId']
# print("data_dic") # print("data_dic")
...@@ -45,6 +47,7 @@ def getColorActivitiesResult(): ...@@ -45,6 +47,7 @@ def getColorActivitiesResult():
return result return result
# Predict route # Predict route
@app.route("/predict", methods=["POST"]) @app.route("/predict", methods=["POST"])
def predict(): def predict():
...@@ -108,6 +111,7 @@ def predict(): ...@@ -108,6 +111,7 @@ def predict():
# return jsonify("print") # return jsonify("print")
# return "Print" # return "Print"
@app.route("/colorSession", methods=['POST']) @app.route("/colorSession", methods=['POST'])
def color_session(): def color_session():
req = request.get_json() req = request.get_json()
...@@ -121,6 +125,7 @@ def color_session(): ...@@ -121,6 +125,7 @@ def color_session():
body = jsonify(data) body = jsonify(data)
return make_response(body) return make_response(body)
# Store activity details route # Store activity details route
@app.route("/store", methods=["POST"]) @app.route("/store", methods=["POST"])
def store(): def store():
...@@ -141,7 +146,8 @@ def store(): ...@@ -141,7 +146,8 @@ def store():
print(e) print(e)
return e return e
#=================================================================================
# =================================================================================
# Read Function Route (IT) # Read Function Route (IT)
# Login # Login
...@@ -171,11 +177,12 @@ def login(): ...@@ -171,11 +177,12 @@ def login():
body = jsonify(data) body = jsonify(data)
return make_response(body) return make_response(body)
@app.route("/logout", methods=['POST']) @app.route("/logout", methods=['POST'])
def logout(): def logout():
req = request.get_json() req = request.get_json()
token = req['token'] token = req['token']
if(logoutUser(token) == 1): if (logoutUser(token) == 1):
response = { response = {
"message": "Success", "message": "Success",
"status": 200 "status": 200
...@@ -183,6 +190,7 @@ def logout(): ...@@ -183,6 +190,7 @@ def logout():
body = jsonify(response) body = jsonify(response)
return make_response(body) return make_response(body)
@app.route("/readingSession", methods=['POST']) @app.route("/readingSession", methods=['POST'])
def reading_session(): def reading_session():
req = request.get_json() req = request.get_json()
...@@ -197,6 +205,19 @@ def reading_session(): ...@@ -197,6 +205,19 @@ def reading_session():
return make_response(body) return make_response(body)
@app.route("/readingSession/<readingToken>", methods=['PUT'])
def reading_session_status_update(readingToken):
assert readingToken == request.view_args['readingToken']
token = readingToken
token = update_session_status(token)
response = {
"message": "Success",
"status": 200
}
body = jsonify(response)
return make_response(body)
@app.route("/reading/<readingToken>", methods=['POST']) @app.route("/reading/<readingToken>", methods=['POST'])
def reading(readingToken): def reading(readingToken):
assert readingToken == request.view_args['readingToken'] assert readingToken == request.view_args['readingToken']
...@@ -214,5 +235,6 @@ def reading(readingToken): ...@@ -214,5 +235,6 @@ def reading(readingToken):
body = jsonify(response) body = jsonify(response)
return make_response(body) return make_response(body)
if __name__ == "__main__": if __name__ == "__main__":
app.run(host='192.168.1.100') app.run(host='192.168.1.100')
from API.db.dbConnection import get_all_data, insert from API.db.dbConnection import *
from flask import jsonify from flask import jsonify
from API.util.util import getUUID from API.util.util import getUUID
def get_reading_activities(): def get_reading_activities():
data_dic = [] data_dic = []
qry = 'SELECT * FROM reading' qry = 'SELECT * FROM reading'
...@@ -32,3 +33,8 @@ def save_session_details(userId, status): ...@@ -32,3 +33,8 @@ def save_session_details(userId, status):
args = (userId, token, status) args = (userId, token, status)
insert(qry, args) insert(qry, args)
return token return token
def update_session_status(token):
qry = 'UPDATE readingSession SET status = 0 WHERE token = "{}"'.format(token)
return update_data(qry)
from API.db.dbConnection import insert, update_data, get_data from API.db.dbConnection import *
from API.util.util import getUUID from API.util.util import getUUID
from datetime import datetime from datetime import datetime
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment