Skip to content

Commit

Permalink
uploads is now not in main but in config
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFJcurve committed Nov 11, 2024
1 parent bedb405 commit 58df30a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
3 changes: 3 additions & 0 deletions backend/code/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
TODO
"""

import os.path

DISCOVERY_PORT = 5000
CHAT_PORT = 5001
MAX_UDP_PACKET = 65507
DISCOVERY_ADDRESS = '192.168.181.255'
UPLOAD_FOLDER = os.path.abspath("../uploads")
9 changes: 1 addition & 8 deletions backend/code/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import io
import json

from code.config import UPLOAD_FOLDER
from code.utils import get_filename_by_file_id, custom_hash
from code.p2p_client import P2PClient
from code.file_tokenizer import SenderTokenizer
Expand All @@ -18,11 +19,6 @@
app = Flask(__name__)
CORS(app)

# Define the folder to save uploaded files
# TODO: Modify UPLOAD_FOLDER to the path you wanna save the received file in locally
UPLOAD_FOLDER = 'uploads' # NOTE: This is a placeholder
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER

# Ensure the upload directory exists
if not os.path.exists(UPLOAD_FOLDER):
os.makedirs(UPLOAD_FOLDER)
Expand Down Expand Up @@ -73,8 +69,6 @@ def receive_token():
data = request.get_json()
file_hash = data.get('final_id')

# TODO process file_hash here and store result in file_path

client.request_file_fingerprint(file_hash)

files = get_filename_by_file_id(file_hash)
Expand All @@ -84,7 +78,6 @@ def receive_token():
return jsonify({"error": "Can't find file hash"}), 400

file_path = os.path.join('sources', files[1])
# file_path='file.txt'

with open(file_path, 'r', encoding="utf-8") as f:
file_with_extension = json.loads(f.read())['header']['file_name']
Expand Down
2 changes: 1 addition & 1 deletion backend/code/p2p_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from code.utils import get_filename_by_file_id
from code.file_tokenizer import ReceiverTokenizer
from config import DISCOVERY_PORT, CHAT_PORT, MAX_UDP_PACKET, DISCOVERY_ADDRESS
from code.config import DISCOVERY_PORT, CHAT_PORT, MAX_UDP_PACKET, DISCOVERY_ADDRESS


class P2PClient:
Expand Down

0 comments on commit 58df30a

Please sign in to comment.