Skip to content

Commit

Permalink
style: format code with Autopep8, Black, ClangFormat, dotnet-format, …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
deepsource-autofix[bot] authored May 11, 2024
1 parent 573789a commit e187fd9
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions app/routes/api.py
Original file line number Diff line number Diff line change
@@ -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/<string:ipfs_hash>', methods=['GET'])
@api.route("/files/<string:ipfs_hash>", 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

0 comments on commit e187fd9

Please sign in to comment.