Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
rp_server_one
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
Ranasinghe R.A.P.T
rp_server_one
Commits
20124b87
Commit
20124b87
authored
Apr 23, 2022
by
Pamal-Ranasinghe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mongodb connection implemented
parent
fb9cb14a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
49 additions
and
3 deletions
+49
-3
app.py
app.py
+34
-2
database/db.py
database/db.py
+6
-0
database/models.py
database/models.py
+8
-0
resources/__pycache__/routes.cpython-38.pyc
resources/__pycache__/routes.cpython-38.pyc
+0
-0
resources/__pycache__/speechExtraction.cpython-38.pyc
resources/__pycache__/speechExtraction.cpython-38.pyc
+0
-0
resources/speechExtraction.py
resources/speechExtraction.py
+1
-1
No files found.
app.py
View file @
20124b87
#import flask module
from
flask
import
Flask
from
flask
import
Flask
,
request
,
jsonify
from
flask_restful
import
Api
from
resources.routes
import
initialize_routes
from
database.models
import
User
from
database.db
import
initialize_db
from
loguru
import
logger
import
json
app
=
Flask
(
__name__
)
api
=
Api
(
app
)
app
.
config
[
'MONGODB_SETTINGS'
]
=
{
'db'
:
'rp_server_one'
,
'host'
:
'localhost'
,
'port'
:
27017
}
initialize_db
(
app
)
# class User(db.Document):
# name = db.StringField()
# email = db.StringField()
# def to_json(self):
# return {"name": self.name,
# "email": self.email}
@
app
.
route
(
'/add'
,
methods
=
[
'POST'
])
def
update_record
():
record
=
request
.
get_json
()
user
=
User
(
name
=
record
[
'name'
],
email
=
record
[
'email'
])
.
save
()
# user.save()
logger
.
info
(
"object"
,
user
)
logger
.
info
(
"record is inserted"
)
return
{
"message"
:
"ok"
}
#Test route
@
app
.
route
(
'/'
)
def
hello_world
():
...
...
database/db.py
0 → 100644
View file @
20124b87
from
flask_mongoengine
import
MongoEngine
db
=
MongoEngine
()
def
initialize_db
(
app
):
db
.
init_app
(
app
)
\ No newline at end of file
database/models.py
0 → 100644
View file @
20124b87
from
.db
import
db
class
User
(
db
.
Document
):
name
=
db
.
StringField
()
email
=
db
.
StringField
()
def
to_json
(
self
):
return
{
"name"
:
self
.
name
,
"email"
:
self
.
email
}
\ No newline at end of file
resources/__pycache__/routes.cpython-38.pyc
View file @
20124b87
No preview for this file type
resources/__pycache__/speechExtraction.cpython-38.pyc
View file @
20124b87
No preview for this file type
resources/speechExtraction.py
View file @
20124b87
...
...
@@ -41,7 +41,7 @@ class SpeechExtraction(Resource):
}
#remove the coverted.wav for get more space in the server
os
.
remove
(
os
.
path
.
join
(
os
.
getenv
(
'CONVERTED_AUDIO_PATH'
),
os
.
getenv
(
'CONVERTED_AUDIO_FILE_NAME'
)
))
os
.
remove
(
os
.
path
.
join
(
"D:/rp_server_one/assets/converted_wav"
,
"converted.wav"
))
#return the json object which is having converted speech
return
json
.
loads
(
json
.
dumps
(
value
)),
200
...
...
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