Prepare for docker

This commit is contained in:
Tyler Perkins 2023-02-24 18:28:52 -05:00
parent 76fe84af98
commit 68dffaba3c
5 changed files with 18 additions and 5 deletions

9
Dockerfile Normal file
View File

@ -0,0 +1,9 @@
FROM python
WORKDIR /usr/src/app
COPY ./src ./
RUN pip install -r requirements.txt
CMD "python" "./app.py"

View File

@ -86,7 +86,9 @@ class addFile(Resource):
if client.addMeme(fileContents=file,
name=fileName,
tags=tags):
return {"message" : "sucess"}
return {"message" : "success", "sucess" : True}
else:
return {"message" : "failure", "success" : False}, 500

View File

@ -8,10 +8,11 @@ import logging
logging.basicConfig(level=logging.DEBUG)
isDebug = True
isDebug = bool(os.environ.get('DEBUG', False))
port = int(os.environ.get('PORT', 5000))
app = Flask(__name__)
api.init_app(app)
app.run(debug=isDebug)
app.run(debug=isDebug, host='0.0.0.0', port=port)

View File

@ -87,6 +87,7 @@ class Client:
self.client = client
else:
raise Exception("Improper object passed for client!")
self.getCurrentMemeList(force=True)
def getCurrentMemeList(self, force=False):
"""
@ -135,8 +136,8 @@ class Client:
tags=tags,
part_size=10*1024*1024)
if result.etag in self.memesToMd5:
logger.info('Uploaded meme named ' + name + ' already exists')
client.remove_object(bucket_name=S3_BUCKET,
logging.info('Uploaded meme named ' + name + ' already exists')
self.client.remove_object(bucket_name=S3_BUCKET,
object_name=name)
return False
else: