Skip to content

Commit

Permalink
send all files via to curl
Browse files Browse the repository at this point in the history
  • Loading branch information
Zelone authored Jun 2, 2024
1 parent f62cd48 commit 4479bdf
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 0 deletions.
49 changes: 49 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -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)


1 change: 1 addition & 0 deletions curl2.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
curl -v -F file=@%1 -F folder=%~dp1 http://localhost:5000/upload
1 change: 1 addition & 0 deletions curl3.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
curl -v -F file=@%1 -F folder=%~dp2 http://localhost:5000/upload
2 changes: 2 additions & 0 deletions folderlist.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
REM dir /A-D /S /B >> r.rr.txt
for /r %%f in (./*) do curl2 %%f
1 change: 1 addition & 0 deletions toexe.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
env\Scripts\pyinstaller --onefile app.py

0 comments on commit 4479bdf

Please sign in to comment.