Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM python:3.8.2-alpine
RUN apk update && pip install flask
COPY src /app/src
WORKDIR /app/src
CMD python3 /app/src/app.py
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: '3'
services:
upload_file_python:
build: .
image: upload_file_python
container_name: upload_file_python
ports:
- 4555:4555
volumes:
- ./src/files:/app/src/files
6 changes: 3 additions & 3 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def index():

@app.route("/upload", methods=["POST"])
def upload():
folder_name = request.form['superhero']
folder_name = 'files'
'''
# this is to verify that folder to upload to exists.
if os.path.isdir(os.path.join(APP_ROOT, 'files/{}'.format(folder_name))):
Expand All @@ -33,7 +33,7 @@ def upload():
filename = upload.filename
# This is to verify files are supported
ext = os.path.splitext(filename)[1]
if (ext == ".jpg") or (ext == ".png"):
if (ext == ".jpg") or (ext == ".png") or (ext == ".sql") or (ext == ".txt") or (ext == ".tar") or (ext == ".py"):
print("File supported moving on...")
else:
render_template("Error.html", message="Files uploaded are not supported...")
Expand All @@ -59,4 +59,4 @@ def get_gallery():


if __name__ == "__main__":
app.run(port=4555, debug=True)
app.run(port=4555, debug=True, host='0.0.0.0')
Empty file added src/files/.gitkeep
Empty file.
4 changes: 2 additions & 2 deletions src/templates/upload.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
//koala.jpg, koala.JPG substring(index) lastIndexOf('a') koala.1.jpg
var ext= input.files[i].name.substring(input.files[i].name.lastIndexOf('.')+1).toLowerCase()

if ((ext == 'jpg') || (ext == 'png'))
if ((ext == 'jpg') || (ext == 'png') || (ext == 'sql') || (ext == 'txt') || (ext == 'tar' || (ext == 'py'))
{
$("#msg").text("Files are supported")
}
Expand All @@ -41,4 +41,4 @@
} );

</script>
</html>
</html>