From 4479bdfd35c375911fa4c6dec2f7ad9161432e64 Mon Sep 17 00:00:00 2001 From: Zelone <34098461+Zelone@users.noreply.github.com> Date: Sun, 2 Jun 2024 17:19:34 +0530 Subject: [PATCH] send all files via to curl --- app.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ curl2.cmd | 1 + curl3.cmd | 1 + folderlist.cmd | 2 ++ toexe.cmd | 1 + 5 files changed, 54 insertions(+) create mode 100644 app.py create mode 100644 curl2.cmd create mode 100644 curl3.cmd create mode 100644 folderlist.cmd create mode 100644 toexe.cmd diff --git a/app.py b/app.py new file mode 100644 index 0000000..a3b1b29 --- /dev/null +++ b/app.py @@ -0,0 +1,49 @@ +from flask import Flask, request, jsonify +import os + +app = Flask(__name__) + +@app.route('/upload', methods=['POST']) +def upload_file(): + print(request.files) + print(request.form) + if 'file' not in request.files: + return jsonify({'error': 'No file part'}), 400 + file = request.files['file'] + folder = './uploads/'+request.form['folder'].replace(':','') + + if file.filename == '': + return jsonify({'error': 'No selected file'}), 400 + + if file: + if os.path.exists(folder): + print("\nDRRRRDD\n") + else: + print('\nDDD\n') + os.makedirs(folder,exist_ok=True) + + + file_path = os.path.join(folder, file.filename) + + file.save(file_path) + + # Example of processing additional data + additional_data = request.form.to_dict() + + return jsonify({'message': 'File and data received successfully', 'data': additional_data}), 200 + + + +@app.route('/makefolder', methods=['POST']) +def make_folder(): + if 'folder' not in request.form: + return jsonify({'error': 'No file part'}), 400 + folder = request.form['folder'] + os.mkdir('./uploads/'+folder) + # Example of processing additional data + return jsonify({'message': 'Folder added successfully', 'data':folder }), 200 + +if __name__ == '__main__': + app.run(debug=True) + + diff --git a/curl2.cmd b/curl2.cmd new file mode 100644 index 0000000..b957558 --- /dev/null +++ b/curl2.cmd @@ -0,0 +1 @@ +curl -v -F file=@%1 -F folder=%~dp1 http://localhost:5000/upload \ No newline at end of file diff --git a/curl3.cmd b/curl3.cmd new file mode 100644 index 0000000..d16cffc --- /dev/null +++ b/curl3.cmd @@ -0,0 +1 @@ +curl -v -F file=@%1 -F folder=%~dp2 http://localhost:5000/upload diff --git a/folderlist.cmd b/folderlist.cmd new file mode 100644 index 0000000..c1839a3 --- /dev/null +++ b/folderlist.cmd @@ -0,0 +1,2 @@ +REM dir /A-D /S /B >> r.rr.txt +for /r %%f in (./*) do curl2 %%f \ No newline at end of file diff --git a/toexe.cmd b/toexe.cmd new file mode 100644 index 0000000..dddf112 --- /dev/null +++ b/toexe.cmd @@ -0,0 +1 @@ +env\Scripts\pyinstaller --onefile app.py \ No newline at end of file