Add size limit

This commit is contained in:
dev
2025-06-14 18:33:16 +02:00
parent 8400f1c3f9
commit e050484b57
2 changed files with 7 additions and 0 deletions
+1
View File
@@ -1,3 +1,4 @@
MAX_CONTENT_LENGTH=1048576
MAX_PENDING_TIME=600 MAX_PENDING_TIME=600
MAX_STORE_TIME=259200 MAX_STORE_TIME=259200
FLASK_DEBUG=0 FLASK_DEBUG=0
+6
View File
@@ -20,6 +20,7 @@ app: Flask = Flask(__name__)
app.json.sort_keys = False # type: ignore app.json.sort_keys = False # type: ignore
app.config["SQLALCHEMY_DATABASE_URI"] = os.environ.get("DB_URI") app.config["SQLALCHEMY_DATABASE_URI"] = os.environ.get("DB_URI")
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
app.config["MAX_CONTENT_LENGTH"] = os.environ.get("MAX_CONTENT_LENGTH")
RESULT_FOLDER.mkdir(parents=True, exist_ok=True) RESULT_FOLDER.mkdir(parents=True, exist_ok=True)
@@ -29,6 +30,11 @@ redis_conn = Redis(host="redis", port=6379)
queue = Queue(connection=redis_conn) queue = Queue(connection=redis_conn)
@app.errorhandler(413)
def too_large(e):
return jsonify({"error": "Image size exceeded"}), 413
@app.route("/") @app.route("/")
def index() -> str: def index() -> str:
"""Render the main index page.""" """Render the main index page."""