Prepare for docker
This commit is contained in:
parent
76fe84af98
commit
68dffaba3c
9
Dockerfile
Normal file
9
Dockerfile
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
FROM python
|
||||||
|
|
||||||
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
|
COPY ./src ./
|
||||||
|
|
||||||
|
RUN pip install -r requirements.txt
|
||||||
|
|
||||||
|
CMD "python" "./app.py"
|
@ -86,7 +86,9 @@ class addFile(Resource):
|
|||||||
if client.addMeme(fileContents=file,
|
if client.addMeme(fileContents=file,
|
||||||
name=fileName,
|
name=fileName,
|
||||||
tags=tags):
|
tags=tags):
|
||||||
return {"message" : "sucess"}
|
return {"message" : "success", "sucess" : True}
|
||||||
|
else:
|
||||||
|
return {"message" : "failure", "success" : False}, 500
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,10 +8,11 @@ import logging
|
|||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
||||||
isDebug = True
|
isDebug = bool(os.environ.get('DEBUG', False))
|
||||||
|
port = int(os.environ.get('PORT', 5000))
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
api.init_app(app)
|
api.init_app(app)
|
||||||
|
|
||||||
app.run(debug=isDebug)
|
app.run(debug=isDebug, host='0.0.0.0', port=port)
|
||||||
|
@ -87,6 +87,7 @@ class Client:
|
|||||||
self.client = client
|
self.client = client
|
||||||
else:
|
else:
|
||||||
raise Exception("Improper object passed for client!")
|
raise Exception("Improper object passed for client!")
|
||||||
|
self.getCurrentMemeList(force=True)
|
||||||
|
|
||||||
def getCurrentMemeList(self, force=False):
|
def getCurrentMemeList(self, force=False):
|
||||||
"""
|
"""
|
||||||
@ -135,8 +136,8 @@ class Client:
|
|||||||
tags=tags,
|
tags=tags,
|
||||||
part_size=10*1024*1024)
|
part_size=10*1024*1024)
|
||||||
if result.etag in self.memesToMd5:
|
if result.etag in self.memesToMd5:
|
||||||
logger.info('Uploaded meme named ' + name + ' already exists')
|
logging.info('Uploaded meme named ' + name + ' already exists')
|
||||||
client.remove_object(bucket_name=S3_BUCKET,
|
self.client.remove_object(bucket_name=S3_BUCKET,
|
||||||
object_name=name)
|
object_name=name)
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
|
Reference in New Issue
Block a user