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
c852b930
Commit
c852b930
authored
Apr 24, 2022
by
Neranga K.T.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
31f5eab9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
1 deletion
+71
-1
backend/IT18256888/__pycache__/app.cpython-39.pyc
backend/IT18256888/__pycache__/app.cpython-39.pyc
+0
-0
backend/IT18256888/app.py
backend/IT18256888/app.py
+71
-1
No files found.
backend/IT18256888/__pycache__/app.cpython-39.pyc
0 → 100644
View file @
c852b930
File added
backend/IT18256888/app.py
View file @
c852b930
...
...
@@ -4,6 +4,13 @@ from keras.layers import Dense,Dropout
from
keras.models
import
Sequential
import
keras.backend
as
K
#creating the tables using sqlalchemy
from
flask_sqlalchemy
import
SQLAlchemy
import
datetime
#serialize and deserialize data
from
flask_marshmallow
import
Marshmallow
scaler_x
=
joblib
.
load
(
'scaler_x.pkl'
)
scaler_y
=
joblib
.
load
(
'scaler_y.pkl'
)
...
...
@@ -53,4 +60,67 @@ def get_level():
results
=
[{
"level"
:
float
(
result
)}]
return
(
jsonify
(
results
=
results
))
app
.
run
(
host
=
'0.0.0.0'
,
port
=
5000
)
userpass
=
'mysql://root:''@'
basedir
=
'127.0.0.1'
dbname
=
'/helply'
socket
=
'?unix_socket=/opt/lampp/var/mysql/mysql.sock'
dbname
=
dbname
+
socket
app
.
config
[
'SQLALCHEMY_DATABASE_URI'
]
=
userpass
+
basedir
+
dbname
app
.
config
[
'SQLALCHEMY_TRACK_MODIFICATIONS'
]
=
False
#DB Connection
db
=
SQLAlchemy
(
app
)
#crate a object of marshmallow
ma
=
Marshmallow
(
app
)
#creating the table
class
MemoryResults
(
db
.
Model
):
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
name
=
db
.
Column
(
db
.
String
(
20
))
age
=
db
.
Column
(
db
.
String
(
10
))
game_level
=
db
.
Column
(
db
.
String
(
50
))
time_duration
=
db
.
Column
(
db
.
Float
())
result
=
db
.
Column
(
db
.
String
(
20
))
date
=
db
.
Column
(
db
.
DateTime
,
default
=
datetime
.
datetime
.
now
)
def
__init__
(
self
,
name
,
age
,
game_level
,
time_duration
,
result
):
self
.
name
=
name
self
.
age
=
age
self
.
game_level
=
game_level
self
.
time_duration
=
time_duration
self
.
result
=
result
#for serializing and deserializing , create the schema
#create Results schema
class
ResultsSchema
(
ma
.
Schema
):
class
Meta
:
fields
=
(
'id'
,
'name'
,
'age'
,
'game_level'
,
'time_duration'
,
'result'
,
'date'
)
# fields to serialize
result_schema
=
ResultsSchema
()
results_schema
=
ResultsSchema
(
many
=
True
)
#add results => POST method
@
app
.
route
(
'/add'
,
methods
=
[
'POST'
])
def
add_result
():
# title = request.json['title']
# body = request.json['body']
name
=
request
.
json
[
'name'
]
age
=
request
.
json
[
'age'
]
game_level
=
request
.
json
[
'game_level'
]
time_duration
=
request
.
json
[
'time_duration'
]
result
=
request
.
json
[
'result'
]
#object of class table
results
=
MemoryResults
(
name
,
age
,
game_level
,
time_duration
,
result
)
#add to the db
db
.
session
.
add
(
results
)
#commit to the db
db
.
session
.
commit
()
return
result_schema
.
jsonify
(
results
)
#run the flask file
if
__name__
==
"__main__"
:
# app.run(debug=True)
app
.
run
(
host
=
'0.0.0.0'
,
port
=
5000
,
debug
=
True
)
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