This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.8" | |
services: | |
app: | |
build: . | |
environment: | |
- FLASK_ENV=development | |
- FLASK_APP=app.py | |
ports: | |
- "5000:5000" | |
volumes: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM python:3.9-alpine | |
ENV PYTHONDONTWRITEBYTECODE 1 | |
ENV PYTHONUNBUFFERED 1 | |
WORKDIR /app | |
COPY . /app | |
RUN pip install --upgrade pip | |
RUN pip install -r /app/requirements.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask | |
from flask_sqlalchemy import SQLAlchemy | |
from config import Config, make_celery | |
db = SQLAlchemy() | |
app = Flask(__name__) | |
app.config.from_object(Config) # Set Flask app configuration from Config class | |
db = SQLAlchemy(app) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import request | |
from http import HTTPStatus | |
from threading import Thread | |
from app import app, db | |
from tasks import upload_task | |
from models import File, UploadStatus | |
from file import process_file_to_stream, upload_file, upload_file_from_stream | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from app import celery | |
from app import db | |
from models import File, UploadStatus | |
from file import upload_file_from_stream | |
@celery.task() | |
def upload_task(file_id: int, file_dict: dict): | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io | |
import boto3 | |
import base64 | |
from datetime import datetime | |
from werkzeug.utils import secure_filename | |
from werkzeug.datastructures import FileStorage | |
from app import app | |
# Setting up S3 client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import enum | |
from sqlalchemy import Enum | |
from app import db | |
class UploadStatus(enum.Enum): | |
""" | |
Serves as enum values for upload_status column of files table | |
(either PENDING, PROCESSING, COMPLETE OR ERROR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from flask import Flask | |
from celery import Celery | |
from dotenv import load_dotenv | |
load_dotenv() | |
class Config: | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SQLALCHEMY_DATABASE_URI=sqlite:///db.sqlite3 | |
SQLALCHEMY_TRACK_MODIFICATIONS=False | |
AWS_ACCESS_KEY=<YOUR_AWS_ACCESS_KEY> | |
AWS_ACCESS_SECRET=<YOUR_AWS_ACCESS_SECRET> | |
S3_BUCKET_NAME=<YOUR_S3_BUCKET_NAME> | |
S3_BUCKET_BASE_URL=<YOUR_S3_BUCKET_BASE_URL> | |
CELERY_BROKER_URL=redis://redis:6379/0 | |
CELERY_RESULT_BACKEND=redis://redis:6379/0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2008-10-17", | |
"Statement": [ | |
{ | |
"Sid": "AllowPublicRead", | |
"Effect": "Allow", | |
"Principal": { | |
"AWS": "*" | |
}, | |
"Action": [ |
NewerOlder