Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
chuk-lo-code
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nisum-DevOps
chuk-lo-code
Commits
a4f8caa0
Commit
a4f8caa0
authored
Mar 04, 2022
by
Waqas Riaz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added flask backend
parent
44646eb0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
0 deletions
+60
-0
app.py
backends/flask-backend/app.py
+44
-0
flask.Dockerfile
backends/flask-backend/flask.Dockerfile
+13
-0
requirements.txt
backends/flask-backend/requirements.txt
+3
-0
No files found.
backends/flask-backend/app.py
0 → 100644
View file @
a4f8caa0
from
flask
import
Flask
import
json
import
logging
import
mariadb
from
os
import
environ
config
=
{
'host'
:
environ
.
get
(
'DB_HOST'
),
'port'
:
int
(
environ
.
get
(
'DB_PORT'
)),
'user'
:
environ
.
get
(
'DB_USER'
),
'password'
:
environ
.
get
(
'DB_PASS'
),
'database'
:
environ
.
get
(
'DB_NAME'
)
}
app
=
Flask
(
__name__
)
gunicorn_error_logger
=
logging
.
getLogger
(
'gunicorn.error'
)
app
.
logger
.
handlers
.
extend
(
gunicorn_error_logger
.
handlers
)
app
.
logger
.
setLevel
(
logging
.
INFO
)
# queries the Menu table and returns the output in json format.
@
app
.
route
(
'/'
,
methods
=
[
'GET'
])
def
index
():
#connection for MariaDB
conn
=
mariadb
.
connect
(
**
config
)
# conn = mysql.connector.connect(**config)
# create a connection cursor
cur
=
conn
.
cursor
()
# execute a SQL statement
cur
.
execute
(
"select * from Employees"
)
# serialize results into JSON
row_headers
=
[
x
[
0
]
for
x
in
cur
.
description
]
rv
=
cur
.
fetchall
()
json_data
=
[]
for
result
in
rv
:
json_data
.
append
(
dict
(
zip
(
row_headers
,
result
)))
# return the results!
return
json
.
dumps
(
json_data
)
if
__name__
==
"__main__"
:
app
.
run
(
host
=
'0.0.0.0'
,
port
=
5000
,
debug
=
True
,
threaded
=
True
)
\ No newline at end of file
backends/flask-backend/flask.Dockerfile
0 → 100644
View file @
a4f8caa0
# syntax=docker/dockerfile:1
FROM ubuntu:focal
WORKDIR /tukkar-app
RUN apt-get update && apt-get install -y libmariadb3 libmariadb-dev python3-pip
COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt
COPY . .
EXPOSE 5000
CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0"]
\ No newline at end of file
backends/flask-backend/requirements.txt
0 → 100644
View file @
a4f8caa0
Flask==2.0.3
gunicorn==20.1.0
mariadb
\ No newline at end of file
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