Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
21_22-J 38
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
21_22-J 38
21_22-J 38
Commits
e20de30c
Commit
e20de30c
authored
May 01, 2022
by
Lihinikaduwa D.N.R.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Read Session Status Done
parent
b2d7c8d9
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
36 additions
and
8 deletions
+36
-8
API/__pycache__/app.cpython-39.pyc
API/__pycache__/app.cpython-39.pyc
+0
-0
API/app.py
API/app.py
+28
-6
API/model/__pycache__/readModel.cpython-39.pyc
API/model/__pycache__/readModel.cpython-39.pyc
+0
-0
API/model/__pycache__/userModel.cpython-39.pyc
API/model/__pycache__/userModel.cpython-39.pyc
+0
-0
API/model/readModel.py
API/model/readModel.py
+7
-1
API/model/userModel.py
API/model/userModel.py
+1
-1
No files found.
API/__pycache__/app.cpython-39.pyc
View file @
e20de30c
No preview for this file type
API/app.py
View file @
e20de30c
...
...
@@ -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'
)
API/model/__pycache__/readModel.cpython-39.pyc
View file @
e20de30c
No preview for this file type
API/model/__pycache__/userModel.cpython-39.pyc
View file @
e20de30c
No preview for this file type
API/model/readModel.py
View file @
e20de30c
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
)
API/model/userModel.py
View file @
e20de30c
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment