Commit 6ba28c5f authored by Lihinikaduwa D.N.R.  's avatar Lihinikaduwa D.N.R.

Merge branch 'it18257632' into 'master'

It18257632

See merge request !173
parents c75f82eb b08fa626
......@@ -4,8 +4,8 @@ import random
import os
from API.model.colorModel import get_color_activities1, get_color_activities2, get_color_activity_result, \
save_color_session_details
from API.model.readModel import get_reading_activities, save_activity_details, save_session_details
from API.model.userModel import getUser, saveUserSession, logoutUser
from API.model.readModel import *
from API.model.userModel import *
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.routers.router import funtion_one
......@@ -20,7 +20,8 @@ app = Flask(__name__)
def home():
return render_template('home.html')
#=================================================================================
# =================================================================================
# Color Function Route (IT18218640)
# Get Color activities 1 route
......@@ -28,15 +29,16 @@ def home():
def getColorActivities1():
return get_color_activities1()
# Get Color activities 2 route
@app.route("/getColorActivities2")
def getColorActivities2():
return get_color_activities2()
# Get Color result route
@app.route("/getColorActivitiesResult")
def getColorActivitiesResult():
req = request.get_json()
userId = req['userId']
# print("data_dic")
......@@ -45,6 +47,7 @@ def getColorActivitiesResult():
return result
# Predict route
@app.route("/predict", methods=["POST"])
def predict():
......@@ -108,6 +111,7 @@ def predict():
# return jsonify("print")
# return "Print"
@app.route("/colorSession", methods=['POST'])
def color_session():
req = request.get_json()
......@@ -121,6 +125,7 @@ def color_session():
body = jsonify(data)
return make_response(body)
# Store activity details route
@app.route("/store", methods=["POST"])
def store():
......@@ -141,7 +146,8 @@ def store():
print(e)
return e
#=================================================================================
# =================================================================================
# Read Function Route (IT)
# Login
......@@ -171,11 +177,12 @@ def login():
body = jsonify(data)
return make_response(body)
@app.route("/logout", methods=['POST'])
def logout():
req = request.get_json()
token = req['token']
if(logoutUser(token) == 1):
if (logoutUser(token) == 1):
response = {
"message": "Success",
"status": 200
......@@ -183,6 +190,7 @@ def logout():
body = jsonify(response)
return make_response(body)
@app.route("/readingSession", methods=['POST'])
def reading_session():
req = request.get_json()
......@@ -197,6 +205,19 @@ def reading_session():
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'])
def reading(readingToken):
assert readingToken == request.view_args['readingToken']
......@@ -214,5 +235,6 @@ def reading(readingToken):
body = jsonify(response)
return make_response(body)
if __name__ == "__main__":
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 API.util.util import getUUID
def get_reading_activities():
data_dic = []
qry = 'SELECT * FROM reading'
......@@ -32,3 +33,8 @@ def save_session_details(userId, status):
args = (userId, token, status)
insert(qry, args)
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 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