init
This commit is contained in:
22
be_getUsers/Dockerfile
Normal file
22
be_getUsers/Dockerfile
Normal file
@ -0,0 +1,22 @@
|
||||
# pull official base image
|
||||
FROM python:3.10-slim-bullseye
|
||||
|
||||
# set work directory
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# set environment variable
|
||||
ENV PYTHONDONTWRITEBYTECODE 1
|
||||
ENV PYTHONUNBUFFERED 1
|
||||
|
||||
# copy project files
|
||||
COPY . /usr/src/app/
|
||||
|
||||
# install python dependencies
|
||||
RUN pip install --upgrade pip
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
# expose the port
|
||||
EXPOSE 5000
|
||||
|
||||
# command to run
|
||||
CMD ["gunicorn", "--workers=3", "--bind=0.0.0.0:5000", "list_app:app"]
|
||||
17
be_getUsers/list_app.py
Normal file
17
be_getUsers/list_app.py
Normal file
@ -0,0 +1,17 @@
|
||||
# list_app.py
|
||||
from flask import Flask, jsonify
|
||||
import os
|
||||
|
||||
app = Flask(__name__)
|
||||
DB_DIR = './data'
|
||||
DB_FILE = f'{DB_DIR}/db.json'
|
||||
|
||||
@app.route('/users')
|
||||
def users():
|
||||
with open(DB_FILE, 'r') as f:
|
||||
data = f.read()
|
||||
|
||||
return data, 200
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host='0.0.0.0', port=5002)
|
||||
8
be_getUsers/requirements.txt
Normal file
8
be_getUsers/requirements.txt
Normal file
@ -0,0 +1,8 @@
|
||||
blinker==1.9.0
|
||||
click==8.3.0
|
||||
Flask==3.1.2
|
||||
itsdangerous==2.2.0
|
||||
Jinja2==3.1.6
|
||||
MarkupSafe==3.0.3
|
||||
Werkzeug==3.1.3
|
||||
gunicorn==20.1.0
|
||||
Reference in New Issue
Block a user