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
e2e2a81b
Commit
e2e2a81b
authored
May 19, 2023
by
supundileepa00
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: Configured logger
parent
b24b2ab2
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
94 additions
and
1 deletion
+94
-1
Project/Backend/Server_Python/.gitignore
Project/Backend/Server_Python/.gitignore
+14
-0
Project/Backend/Server_Python/__pycache__/main.cpython-310.pyc
...ct/Backend/Server_Python/__pycache__/main.cpython-310.pyc
+0
-0
Project/Backend/Server_Python/app.log
Project/Backend/Server_Python/app.log
+4
-0
Project/Backend/Server_Python/controllers/__pycache__/translate_controler.cpython-310.pyc
...ntrollers/__pycache__/translate_controler.cpython-310.pyc
+0
-0
Project/Backend/Server_Python/controllers/translate_controler.py
.../Backend/Server_Python/controllers/translate_controler.py
+24
-0
Project/Backend/Server_Python/core/__init__.py
Project/Backend/Server_Python/core/__init__.py
+23
-0
Project/Backend/Server_Python/core/__pycache__/__init__.cpython-310.pyc
...d/Server_Python/core/__pycache__/__init__.cpython-310.pyc
+0
-0
Project/Backend/Server_Python/core/__pycache__/logger.cpython-310.pyc
...end/Server_Python/core/__pycache__/logger.cpython-310.pyc
+0
-0
Project/Backend/Server_Python/core/logger.py
Project/Backend/Server_Python/core/logger.py
+0
-0
Project/Backend/Server_Python/main.py
Project/Backend/Server_Python/main.py
+26
-1
Project/Backend/Server_Python/requirements.txt
Project/Backend/Server_Python/requirements.txt
+3
-0
Project/Backend/Server_Python/services/__init__.py
Project/Backend/Server_Python/services/__init__.py
+0
-0
No files found.
Project/Backend/Server_Python/.gitignore
0 → 100644
View file @
e2e2a81b
# Ignore video files
*.mp4
*.avi
*.mov
*.mkv
*.flv
*.wmv
*.mpeg
*.mpg
*.3gp
*.webm
*.vob
*.m4v
*.ts
\ No newline at end of file
Project/Backend/Server_Python/__pycache__/main.cpython-310.pyc
View file @
e2e2a81b
No preview for this file type
Project/Backend/Server_Python/app.log
0 → 100644
View file @
e2e2a81b
2023-05-19 00:32:23,385 - INFO - Received request at root endpoint.
2023-05-19 00:32:23,385 - INFO - Received request at root endpoint.
2023-05-19 00:32:48,522 - ERROR - Received request at root endpoint.
2023-05-19 00:32:48,522 - ERROR - Received request at root endpoint.
Project/Backend/Server_Python/controllers/__pycache__/translate_controler.cpython-310.pyc
0 → 100644
View file @
e2e2a81b
File added
Project/Backend/Server_Python/controllers/translate_controler.py
0 → 100644
View file @
e2e2a81b
from
fastapi
import
APIRouter
,
File
,
HTTPException
,
UploadFile
from
core
import
setup_logger
router
=
APIRouter
()
logger
=
setup_logger
()
@
router
.
post
(
"/upload/video"
)
async
def
upload_video
(
video
:
UploadFile
=
File
(
...
)):
try
:
# Save the uploaded video to the "uploads" folder
logger
.
info
(
"Received request at root endpoint."
)
file_location
=
f
"files/{video.filename}"
with
open
(
file_location
,
"wb"
)
as
file
:
file
.
write
(
video
.
file
.
read
())
return
{
"filename"
:
video
.
filename
}
except
Exception
as
e
:
logger
.
info
(
f
"Failed to upload file. {e}"
)
raise
HTTPException
(
status_code
=
500
,
detail
=
"Failed to upload the video"
)
\ No newline at end of file
Project/Backend/Server_Python/core/__init__.py
0 → 100644
View file @
e2e2a81b
import
logging
def
setup_logger
():
logger
=
logging
.
getLogger
(
__name__
)
logger
.
setLevel
(
logging
.
DEBUG
)
formatter
=
logging
.
Formatter
(
'
%(asctime)
s -
%(levelname)
s -
%(message)
s'
)
# Create a file handler for logging to a file
file_handler
=
logging
.
FileHandler
(
'app.log'
)
file_handler
.
setLevel
(
logging
.
DEBUG
)
file_handler
.
setFormatter
(
formatter
)
# Create a stream handler for logging to console
stream_handler
=
logging
.
StreamHandler
()
stream_handler
.
setLevel
(
logging
.
INFO
)
stream_handler
.
setFormatter
(
formatter
)
# Add the handlers to the logger
logger
.
addHandler
(
file_handler
)
logger
.
addHandler
(
stream_handler
)
return
logger
Project/Backend/Server_Python/core/__pycache__/__init__.cpython-310.pyc
0 → 100644
View file @
e2e2a81b
File added
Project/Backend/Server_Python/core/__pycache__/logger.cpython-310.pyc
0 → 100644
View file @
e2e2a81b
File added
Project/Backend/Server_Python/core/logger.py
0 → 100644
View file @
e2e2a81b
Project/Backend/Server_Python/main.py
View file @
e2e2a81b
from
fastapi
import
FastAPI
from
controllers
import
users_controller
from
controllers
import
translate_controler
,
users_controller
from
fastapi.responses
import
RedirectResponse
from
fastapi.middleware.cors
import
CORSMiddleware
from
core
import
setup_logger
app
=
FastAPI
()
logger
=
setup_logger
()
app
.
include_router
(
users_controller
.
router
)
app
.
include_router
(
translate_controler
.
router
)
# Add cores middleware
origins
=
[
"http://localhost"
,
"http://localhost:8080"
,
]
app
.
add_middleware
(
CORSMiddleware
,
allow_origins
=
origins
,
allow_credentials
=
True
,
allow_methods
=
[
"*"
],
allow_headers
=
[
"*"
])
@
app
.
get
(
'/'
)
async
def
root
():
url
=
app
.
docs_url
or
'/docs'
return
RedirectResponse
(
url
)
\ No newline at end of file
Project/Backend/Server_Python/requirements.txt
0 → 100644
View file @
e2e2a81b
fastapi
uvicorn
python-multipart==0.0.6
\ No newline at end of file
Project/Backend/Server_Python/services/__init__.py
0 → 100644
View file @
e2e2a81b
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