Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2023-029
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
2023-029
2023-029
Commits
32b029be
Commit
32b029be
authored
Sep 02, 2023
by
Sumudu-Himasha-Ranaweera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: update
Desc : update project
parent
504beb2c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
23 deletions
+26
-23
Project/Backend/Server_Python/controllers/video_to_sign_language_controller.py
...r_Python/controllers/video_to_sign_language_controller.py
+6
-3
Project/Backend/Server_Python/main.py
Project/Backend/Server_Python/main.py
+20
-20
No files found.
Project/Backend/Server_Python/controllers/video_to_sign_language_controller.py
View file @
32b029be
from
datetime
import
datetime
import
moviepy.editor
as
mp
import
requests
import
speech_recognition
as
sr
from
core
import
setup_logger
from
fastapi
import
APIRouter
,
File
,
HTTPException
,
UploadFile
from
fastapi.responses
import
JSONResponse
from
pymongo.mongo_client
import
MongoClient
from
core.logger
import
setup_logger
# Replace with your MongoDB Atlas credentials
username
=
"admin"
password
=
"JppbU6MZeHfOj7sp"
...
...
@@ -118,6 +118,7 @@ def translate_text(text, target_language):
# status_code=500, detail="Failed to update or create translated item"
# )
# v3
def
send_to_mongodb
(
translated_integer_si
):
translated_item_data
=
{
...
...
@@ -137,4 +138,6 @@ def send_to_mongodb(translated_integer_si):
result
=
items_collection
.
replace_one
({},
translated_item_data
,
upsert
=
True
)
if
result
.
matched_count
==
0
and
result
.
modified_count
==
0
:
raise
HTTPException
(
status_code
=
500
,
detail
=
"Failed to update or create translated item"
)
raise
HTTPException
(
status_code
=
500
,
detail
=
"Failed to update or create translated item"
)
Project/Backend/Server_Python/main.py
View file @
32b029be
# from core import setup_logger
from
fastapi
import
FastAPI
from
controllers
import
translate_controler
,
users_controller
,
video_to_sign_language_controller
from
fastapi.responses
import
RedirectResponse
from
fastapi.middleware.cors
import
CORSMiddleware
from
pymongo.mongo_client
import
MongoClient
from
controllers
import
(
translate_controler
,
users_controller
,
video_to_sign_language_controller
)
# from controllers import translate_controler, users_controller
from
pymongo.mongo_client
import
MongoClient
#
from core.logger import setup_logger
app
=
FastAPI
()
from
core.logger
import
setup_logger
app
=
FastAPI
()
# Replace with your MongoDB Atlas credentials
username
=
"admin"
...
...
@@ -18,6 +17,7 @@ client = MongoClient(uri)
db
=
client
[
"test"
]
items_collection
=
db
[
"translated_items"
]
@
app
.
on_event
(
"startup"
)
async
def
startup_db_client
():
app
.
mongodb_client
=
MongoClient
(
uri
)
...
...
@@ -33,30 +33,30 @@ async def shutdown_db_client():
app
.
mongodb_client
.
close
()
# logger = setup_logger()
logger
=
setup_logger
()
app
.
include_router
(
users_controller
.
router
)
app
.
include_router
(
translate_controler
.
router
)
app
.
include_router
(
video_to_sign_language_controller
.
router
)
# Add cores middleware
origins
=
[
"http://localhost"
,
"http://localhost:8080"
,
"http://127.0.0.1:8000"
,
"http://localhost:8004"
,
"http://localhost:3000"
,
"http://127.0.0.1:8000"
]
app
.
add_middleware
(
CORSMiddleware
,
allow_origins
=
origins
,
allow_credentials
=
True
,
allow_methods
=
[
"*"
],
allow_headers
=
[
"*"
],
)
app
.
add_middleware
(
CORSMiddleware
,
allow_origins
=
origins
,
allow_credentials
=
True
,
allow_methods
=
[
"*"
],
allow_headers
=
[
"*"
])
@
app
.
get
(
"/"
)
async
def
read_root
():
return
{
"message"
:
"FastAPI with MongoDB integration"
}
\ No newline at end of file
@
app
.
get
(
'/'
)
async
def
root
():
url
=
app
.
docs_url
or
'/docs'
return
RedirectResponse
(
url
)
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