From e187fd96c0aec7501505b4e5fff0651bd697289d Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Sat, 11 May 2024 07:53:30 +0000 Subject: [PATCH] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 573789a according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- app/routes/api.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/app/routes/api.py b/app/routes/api.py index 41d40cc..0909239 100644 --- a/app/routes/api.py +++ b/app/routes/api.py @@ -1,29 +1,32 @@ # API routes -from flask import Blueprint, request, jsonify -from app.services.ipfs import IPFS -from app.services.encryption import encrypt_file +from flask import Blueprint, jsonify, request + from app.models import File, User +from app.services.encryption import encrypt_file +from app.services.ipfs import IPFS + +api = Blueprint("api", __name__) -api = Blueprint('api', __name__) -@api.route('/files', methods=['POST']) +@api.route("/files", methods=["POST"]) def upload_file(): - file = request.files['file'] - user = User.query.filter_by(username=request.form['username']).first() + file = request.files["file"] + user = User.query.filter_by(username=request.form["username"]).first() if user: encrypted_file = encrypt_file(file) ipfs_hash = IPFS.add(encrypted_file) file = File(name=file.filename, content=ipfs_hash, user=user) db.session.add(file) db.session.commit() - return jsonify({'message': 'File uploaded successfully'}) - return jsonify({'message': 'User not found'}), 404 + return jsonify({"message": "File uploaded successfully"}) + return jsonify({"message": "User not found"}), 404 + -@api.route('/files/', methods=['GET']) +@api.route("/files/", methods=["GET"]) def download_file(ipfs_hash): file = File.query.filter_by(ipfs_hash=ipfs_hash).first() if file: encrypted_file = IPFS.get(ipfs_hash) decrypted_file = decrypt_file(encrypted_file) return send_file(decrypted_file, as_attachment=True) - return jsonify({'message': 'File not found'}), 404 + return jsonify({"message": "File not found"}), 404